Reviving this old thread. I'm trying to set max and min zooms in my map. I want the initial (max) extent to be zoom level 3, and I don't want to be able to zoom in any further than level 15 or so (min extent). I found a snippet of JS that works for the first part, and I'm trying to adapt it to work for the second. I think my issue is how I'm trying to set the minimum extent. I only want a lat/lon center point for the maximum (initial) extent. Here is the code snippet. The first if statement works but the else if does not.
map = new Map("map", {
basemap: "streets",
center: [-105, 45],
zoom: 3
});
dojo.connect(map, "onLoad", function(){
maxExtent = map.extent;
minExtent = ("map", {
zoom: 15
});
});
dojo.connect(map, "onExtentChange", function(extent){
if((map.extent.xmin < maxExtent.xmin) ||
(map.extent.ymin < maxExtent.ymin) ||
(map.extent.xmax > maxExtent.xmax) ||
(map.extent.ymax > maxExtent.ymax)
) {
map.setExtent(maxExtent);
}
else if((map.extent.xmin > minExtent.xmin) ||
(map.extent.ymin > minExtent.ymin) ||
(map.extent.xmax < minExtent.xmax) ||
(map.extent.ymax < minExtent.ymax)
) {
map.setExtent(minExtent);
}
});