katit katit - 11 months ago 49
C# Question

ESRI Map control PanTo

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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download