Select to view content in your preferred language

replacements of Envelope.Expand and Map.CenterAt()

2601
4
06-17-2010 09:50 AM
ThaoNguyen
Emerging Contributor
Before, we use ESRI.ArcGIS.MapControl.AxMapControl for the map object, now we switch to esri wpf which uses esri.arcgis.client.Map.
Before, to zoom in, we do the following:
<AxMapControl instance>.CenterAt(mapPoint)
ESRI.ArcGIS.esriSystem.IClone clone = axMapControl.Extent as ESRI.ArcGIS.esriSystem.IClone;
IEnvelope envelope = clone.Clone() as IEnvelope;
envelope.Expand(0.50, 0.50, true);

To zoom out: envelope.Expand(1.25,1.25,true);

In wpf api, I cannot find the Expand() or CenterAt() for Map.  Please advise what I can use in replacements of these methods.

Thanks!!
0 Kudos
4 Replies
dotMorten_esri
Esri Notable Contributor
map.ZoomTo(geometry);  //zooms to the extent of the provided geometry
map.Zoom(2.0); //zoom in 2 times the scale
map.Zoom(.5); //zoom out 2 times the scale

CenterAt:
map.PanTo(geometry); //centers at the center of the provided geometry
0 Kudos
ThaoNguyen
Emerging Contributor
map.ZoomTo(geometry);  //zooms to the extent of the provided geometry
map.Zoom(2.0); //zoom in 2 times the scale
map.Zoom(.5); //zoom out 2 times the scale

CenterAt:
map.PanTo(geometry); //centers at the center of the provided geometry



I tried map.Panto(mapPoint) but it didn't seem to work for me because sometimes the point where I clicked was not in the view.  I did the following, and everytime I zoomed in, the center of the map was zoomed, not where my clicked point was zoomed.
map.PanTo(mapPoint);
map.Zoom(2);
0 Kudos
ThaoNguyen
Emerging Contributor
BTW, if I draw a rectangle, not a point, I can just do myMap.ZoomTo(geometry), this will zoom to the area drawn.  However, if the geometry is a MapPoint, it doesn't work as I want.  I also try to create a rectangle using the point but I don't know what numbers I can come up with that do the right zoom.
0 Kudos
dotMorten_esri
Esri Notable Contributor
You cannot zoom to a point, because it doesn't have a valid extent to zoom to. The reason is basically the same as the problem you are facing: The map can't know how far in you meant to zoom around that point. It really depends on the type of data (ie you want to zoom further in if the point represents an address, but not as far if its a city).

If you need to zoom around a certain point, use myMap.ZoomToResolution(myMap.Resolution/2, pointToZoomAround);

Also you cannot call PanTo right after calling ZoomTo or vice versa. Calling one of these commands will stop any other active navigation (like the previous one you just called).
0 Kudos