Unable to centre the point feature when zooming to the particular scale in the map.

09-21-2012 04:24 AM
New Contributor
Hi All,

I have to do the following tasks,
  1. pan the point feature to centre of the screen.
  2. zoom to the point feature at specific scale.

I am able to pan the feature to centre of the screen and after that I am able to zoom to the specific scale. But point feature was not centred.

0 Kudos
1 Reply
Esri Frequent Contributor
I guess there is an issue becasue PanTo and ZoomTo are asynchronous functions (with animations), so executing bothh in // may be an issue.

Here is an example of function panning and zooming with only one call:

private void centerAndZoom(ESRI.ArcGIS.Client.Map map, ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint, double resolution)
double ratio = 1.0;
if (map.Resolution != 0.0)
ratio = resolution / map.Resolution;

if (ratio == 1.0)
ESRI.ArcGIS.Client.Geometry.MapPoint mapCenter = map.Extent.GetCenter();
double X = (mapPoint.X - ratio * mapCenter.X) / (1 - ratio);
double Y = (mapPoint.Y - ratio * mapCenter.Y) / (1 - ratio);
map.ZoomToResolution(resolution, new ESRI.ArcGIS.Client.Geometry.MapPoint(X, Y));

Note : it's using Map.Resolution but might easily be adpated to use Map.Scale.
0 Kudos