Dynamic Map Service: Go to a specific scale and pan to point

727
1
11-02-2010 11:05 AM
DanielYim
New Contributor II
I am using an ArcGISDynamicMapService, and given a point, I want the map to zoom out (or into) a specific scale and pan to a location.

With dynamic maps, I can't find a way to set the scale manually, unlike what the level of detail (LOD) does for tiled maps. Is there something for dynamic maps where I can set a scale?


I appreciate any input. Thanks.
0 Kudos
1 Reply
DanielYim
New Contributor II
I made a solution to those who will encounter a similar problem:

Using my map, I zoomed out/in to the scale that I wanted to and made a dummy button that logged what's returned from esri.geometry.getScale(myMap) to get the current scale. Using that number, I used myMap.setExtent(esri.geometry.getExtentForScale(myMap, <scale number>)); to make the map zoom out or in to the scale that I want from the current view. My organization's maps take longer than usual for extent changes, so I made an event listener for the dynamic map service's onUpdateEnd to wait for the extent change to load and then center the map at the geometry that I needed.

Here's my code for reference. For me, 44315.3858 is what was returned from esri.geometry.getScale(myMap). parcelMap is my ArcGISDynamicMapServiceLayer.
function reduceExtent(geom) {
    // Adjust the current extent to the specified scale where we can see
    // abstracts
    myMap.setExtent(esri.geometry.getExtentForScale(myMap, 44315.3858));
    
    // Wait until the extent change has completed
    var tempHook = dojo.connect(parcelMap, "onUpdateEnd", function() {
        // Pan to the selected abstract
        myMap.centerAt(geom.getExtent().getCenter());
        // Dispose of the temporary listener
        dojo.disconnect(tempHook);        
    });
}


I hope this helps someone.
0 Kudos