Select to view content in your preferred language

SFV 1.0, Web Mercator base maps:  Locate and Banner in 102100 rather than 4326

3132
10
04-14-2010 05:01 AM
ThomasBrophy
Regular Contributor
All,
I have moved to the web mercator base maps, the locate no longer works and the xy in the banner displays in 102100 rather than 4326.

I am in the same situation that Bobby was in at his post, "Locate and Web Mercator "
http://forums.esri.com/Thread.asp?c=158&f=2421&t=300183&mc=7#msgid938108

I have implemented,

1.)  "New Locate Widget for Sample Viewer that Pojects Results" from:
http://resources.esri.com/arcgisserver/apis/flex/index.cfm?fa=codeGalleryDetails&scriptID=16359

2.)  "Project Mouse Coordinates on MouseOver" forum by Robert Scheitlin from:
http://forums.esri.com/Thread.asp?c=158&f=2421&t=300161&mc=8


*** Problem:
Using the  2.), the banner is working in WGS84 (4326).  -77.000, 38.000
Using the  1.), The geocode address works.

When I use xy locate at -77.000, 38.000:  The livemaps layers get very small (1:1,128), and in relation to those layers, the point is right - but according to the application banner it is 0.000,0.000.  Weird!



I should note that I am using the "Shortcut Menu and Coordinate Display in the Banner (Combine.zip)" by Robert Scheitlin from forum:
http://forums.esri.com/Thread.asp?c=158&f=2421&t=301764&mc=4


Can anyone tell me what I am missing?
Thomas Brophy



---------------------------------------------------------------------------
LocateWidget3.xml code change:
<inspatial>4326</inspatial>
<outspatial>102100</outspatial>
---------------------------------------------------------------------------
LocateWidget3.mxml code change:
Line: 133

     inSpatial = configXML.inspatial || 4326;
     outSpatial = configXML.outspatial || 102100;
---------------------------------------------------------------------------
Banner.mxml code change:
Line 75:

//Original code  
   /*
   private function mouseMoveHandler(event:MouseEvent):void
   {
    const mapPoint:MapPoint = _map.toMapFromStage(event.stageX, event.stageY);
                mapXY = "Long: "+ mapPoint.x.toFixed(4) + ", Lat: " + mapPoint.y.toFixed(4);
            }
            */
//Original code end
           
//Project Mouse Coordinates on MouseOver fix
   private function mouseMoveHandler(event:MouseEvent):void
   { 
    const mapPoint:MapPoint = _map.toMapFromStage(event.stageX, event.stageY); 
    const nMPnt:MapPoint = WebMercatorUtil.webMercatorToGeographic(mapPoint,true) as MapPoint;
    mapXY = "X: "+ nMPnt.x.toFixed(4) + ", Y: " + nMPnt.y.toFixed(4);
   }          
//Project Mouse Coordinates on MouseOver fix end
---------------------------------------------------------------------------
0 Kudos
10 Replies
by Anonymous User
Not applicable
Original User: rscheitlin

Thomas,

   This right here from your attached config.xml tells me that your map is still in WGS 1984 and not web-mercator.
<map initialExtent="-122.2 24.89 -70.59 46.92" fullExtent="-150 -50 150 50">
  <basemaps menu="menuMap">
   <mapservice label="Street Map" type="tiled" visible="true" alpha="1" icon="com/esri/solutions/flexviewer/assets/images/icons/i_highway.png">http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer</mapservice>
   <mapservice label="Satellite Map" type="tiled" visible="false" alpha="1" icon="com/esri/solutions/flexviewer/assets/images/icons/i_shuttle.png">http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer</mapservice>   
  </basemaps>
  <livemaps>
   <mapservice label="CST Team Information" type="dynamic" visible="true" alpha="1.0">http://214.3.33.103/ArcGIS/rest/services/cstsec_loc/MapServer</mapservice> 
  </livemaps>
 </map>


You are still using a 4326 extent and you are still using the old 4326 map services...?
0 Kudos
ThomasBrophy
Regular Contributor
Attached is the right one.  (The other fioles are right)
0 Kudos
by Anonymous User
Not applicable
Original User: tbrophy

my services are in 102100, but the SDE layers in those services are in WGS84.  Should this make a difference?  I ask this because I use these same layers in services that are in 4326 as well.
0 Kudos
by Anonymous User
Not applicable
Original User: rscheitlin

Thomas,

   OK, pretty simple. I did not expect people to enter a coordinate that was in a different projection than the map was in so when you entered a 4326 coordinate it stayed just that and was not converted. Here is the code to change in the Locate Widget to handle the projecting of the coordinate to web mercator.

private function locateCoordinates():void
   {
    graphicsLayer.clear();
    WidgetEffects.flipWidget(this, viewStack, "selectedIndex", 2, 400);
    try
    {
     var long:String = txtLong.text;
     var lat:String = txtLat.text;
     if ((long) && (lat))
     {
      var point:MapPoint = new MapPoint(Number(long), Number(lat));
      var wmPnt:MapPoint = WebMercatorUtil.geographicToWebMercator(point,true) as MapPoint;
      var icon:String = widgetIcon;
      var title:String = coordinatesLabel;  
      var content:String = long.toString() + ", " + lat.toString();
      var link:String = "";
      var infoData:Object = 
      {
       icon: icon, 
       title: title, 
       content: content, 
       link: link, 
       point: wmPnt,
       geometry: wmPnt
      };
      var recAC:ArrayCollection =  new ArrayCollection([infoData]);                
      wRepeater.dataProvider = recAC;
      this.addSharedData(widgetTitle, recAC);
      showLocation(infoData);
      showMessage(locationsLabel, false);
     }
    }
    catch (error:Error)
    {
     showMessage(error.message, false);
    }
   }


of course don't forget to import the webmercatorutil.
import com.esri.ags.utils.WebMercatorUtil;
0 Kudos
ThomasBrophy
Regular Contributor
Thank you Robert.  I really appreciate it!!!

Can you tell me how to mark this as answered?
0 Kudos
by Anonymous User
Not applicable
Original User: rscheitlin

Thomas,

   Marking threads as answered will not begin until next month when the current MVP program on the old forum is finished. 😞
0 Kudos
ThomasBrophy
Regular Contributor
I'll just come back next month and complete this one.  Thanks again.
0 Kudos
ThomasBrophy
Regular Contributor
Robert,

You just helped me with my banner and the locateWidet.  I really appreciate it!!  But now my GeoRSS, Bookmark and Sreach Widgets are acting the same way.
Using any of these widgets moves all data (spatially oriented correctly) small and to the center of the map. (see printscreen.jpg)

In January we discussed a lot of these issues on the forum, "RSS feeds in Web Mercator for Bing Maps":
http://forums.esri.com/Thread.asp?c=158&f=2421&t=299011&mc=9#934524

Can you help me with this adjustment?  It seems the changes we made for the banner and locate effected these other widgets. . .  I'm not sure what happening.
0 Kudos
by Anonymous User
Not applicable
Original User: rscheitlin

Thomas,

   Who would have thought.... I found the error, replace this line in the Banner.mxml MouseMoveHandler function
const nMPnt:MapPoint = WebMercatorUtil.webMercatorToGeographic(mapPoint,false) as MapPoint;

Notice the false where it use to be true somehow if you leave this true then that can change the whole maps spatial reference to 4326 and not just that point.
0 Kudos