Select to view content in your preferred language

Converting WGS84 Point to Maps Current Spatial Reference

2158
2
05-24-2010 12:17 PM
JeffSmith3
Deactivated User
I need to convert a WGS84 Lat/Lon point to my MapServices Spatial Reference. In this case, it happens to be Nad83.
Is there a typesafe way to convert a lat/lon point that I am receiving into whatever spatial reference my program is currently grabbing from the MapService it is looking at?
What libraries should I be looking at? Any examples would be great. Thank you.
0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor
You should use the GeometryService task for performing re-projection.

However, in most cases the server handles projecting on the fly in most cases (ie you can request and submit data in different SRs and it will project for you). What is the use case?
0 Kudos
JeffSmith3
Deactivated User
In this case I am creating a new WGS84 Map Point, and trying to plot it on a Nad83 Spatial Ref.

           
            double lat = message.Latitude;
            double lon = message.Longitude;

            MapPoint mp = new MapPoint(lon, lat, new SpatialReference(4326));

            _pointLayer.Graphics.Clear();

            Graphic graphic = new Graphic()
            {
                Geometry = mp,
                Symbol = new SimpleMarkerSymbol() { Color = new SolidColorBrush(Colors.Blue), Size = 10 }
            };

            _pointLayer.Graphics.Add(graphic);


In this case _pointLayer is a Nad83 DynamicMapServiceLayer.
It throws an exception saying that the Graphic must match the SpatialRef of the service. Thanks again for the help.
0 Kudos