1

I'm trying to make map center on certain Latitude/Longitude but Esri map control uses it's own X/Y coordinate system.

control.MapControl.PanTo(new MapPoint(control.MapCenter.Latitude, control.MapCenter.Longitude));

This code does not work. Is there any "conversion" routine to get MapPoint out of Lat/Lon or what should I do?

Vikash Pandey
  • 5,407
  • 6
  • 41
  • 42
katit
  • 17,375
  • 35
  • 128
  • 256

1 Answers1

1

The method I use for conversion from lat/long(spatial reference 4326) to Esri coordinates (spatial reference 102100) is as follows:

// Create mappoint with lat/long coordinates
var mapPoint = new MapPoint(long, lat);

// Need to convert from Lat/Long to Esri
var webMercator = new WebMercator();
var converted = (MapPoint) webMercator.FromGeographic(mapPoint);

Before doing the conversion step, you can also check the spatial reference of mapPoint to see if it needs to be converted.

Max Hampton
  • 1,254
  • 9
  • 20
  • Just to clarify: This is not "esri coordinates". These are coordinates in the Mercator Map Projection (likely because you're using a set of layers that puts it in that projection). The Esri map control can work with any map projection, but it also means you would have to convert to that projection if you have longitude/latitude geographic coordinates as input. Also check out the new Esri .NET map control which will do this conversion for you most of the time (http://developers.arcgis.com/net) – dotMorten Oct 18 '14 at 04:38