Map.ZoomTo using graphic geometries

3261
2
11-07-2011 06:02 AM
Labels (1)
CliffordPadgett
New Contributor
I am using the following maps from the available arcgis servers

base layer:
http://services.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer

state boundaries layer:
http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5

layer used for city information:
http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/Map...

I can easily be anywhere on the map and call Zoom.To and provide any graphic's extent from the state layer and the map will show as expected. However when attempting to do the same thing with any of the city layer's graphics, the function fails to do anything at all.

What might the reason for this be?

In an attempt to narrow down possibilities, I have tried using Map.PanTo and provide the same geometry information, this function works and behaves as expected. (except it only pans, I would also like to zoom to the minimum resolution, however I have tried map.zoomToResolution while providing map points.)

In the end what I would like to do is provide functionality for zooming in on a clicked location. I am currently providing the geometry information through an event handler to the map and calling the methods there with the provided args.

Any direction would be helpful.

Thanks.
0 Kudos
2 Replies
CliffordPadgett
New Contributor
Issue has been resolved. I didn't realize that geometries provided for ZoomTo() needed an area (height / width) meaning that the X/Y min/max differed.

Unfortunately creating map points with GPScoordinates results in map points with no area.
0 Kudos
MelindaFrost
Occasional Contributor
You can create a new envelope using the Envelope Constructor(Coordinate,Double,Double)
where coordinate is your point
first double is the width
second double is the height

Basically create a extent for your point. What width and height will be depends on how zoomed in you want. I have used like 25 feet for width and height in one of my apps.
Then just pass into Map.ZoomTo()
0 Kudos