I want to limit map extent to the initial extent of the map and limit user from panning more than certain extent.
I tried following but nothing has changed:
map = new Map( "map" , {
basemap: "gray",
center: [-85.416, 49.000],
zoom : 6,
logo: false,
sliderStyle: "small"
});
var imageParameters = new ImageParameters();
imageParameters.format = "PNG";
dojo.connect(map,"onLoad",function(){
var initExtent = map.extent;
dojo.create("div",{
className: "esriSimpleSliderHomeButton",
onclick: function(){
map.setExtent(initExtent);
}
},dojo.query(".esriSimpleSliderIncrementButton")[0], "after");
});
dojo.connect(map, "onExtentChange", function (){
var initExtent = map.extent;
var extent = map.extent.getCenter();
if(initExtent.contains(extent)){}
else{map.setExtent(initExtent)}
});
1 Answer 1
I've had success with a similar approach, but instead of setting the map extent to the inital extent, I panned the map back to a point in the initial extent.
See http://jsfiddle.net/bbunker/JP565/ for an example. Hope it helps.
Explore related questions
See similar questions with these tags.