zoom

615
6
11-03-2010 08:50 AM
timgogl
New Contributor II
i have been searching through the api here and have not seen what i am looking for; of course that does not mean it doesn't exsist.

is there a zoomToExtent() function? or has anyone hacked one up that they would be willing to share? if one exsists, i would appreciate a link to the appropriate page.

thanks so much.
0 Kudos
6 Replies
DanielYim
New Contributor II
This functionality is similar to what I am looking for in the thread that I made not to long ago (here if you want to see it).

Maybe together we can concoct a solution?
0 Kudos
timgogl
New Contributor II
yes, i have seen another similar post a while back, cant remember if i was searching for a solution then or i just stumbled on it randomly.

i'm guessing we may need to roll our own. if i can avoid the constant distractions and diversion, i may be able to work something out.... i don't know heh. i sometimes seem to have difficulties with the simplest of things.
0 Kudos
derekswingley1
Frequent Contributor
0 Kudos
DanielYim
New Contributor II
You can try adding a transparent "dummy graphic" to your map's GraphicLayer with the graphic's geometry set to the extent you want. Then, extract a Point object from that graphic using getCenter(), and send that over to map.centerAt(thatPoint).

I may be running around in circles, but it's a possible solution.
0 Kudos
timgogl
New Contributor II
well. i think map.setExtent(extent,true); will work for me. thanks for the link swingley. points dont seem to have extents, but i think i can work around that with map.centerAndZoom();
0 Kudos
MarcelKleinmann
New Contributor
My solution:
a zoom function, which zooms to a bounding box


function setBBOX(xMin, yMin, xMax, yMax){
var newExtent = new esri.geometry.Extent();
newExtent.xmin = xMin;
newExtent.ymin = yMin;
newExtent.xmax = xMax;
newExtent.ymax = yMax;
newExtent.spatialReference = new esri.SpatialReference({ wkid: 31466});

map.setExtent(newExtent);
}


The wkid refers to the spatial reference of the map, see Esri Java Srcipt Api Site

Cheers
0 Kudos