0

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)}
 });
asked Mar 18, 2014 at 15:37

1 Answer 1

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.

answered Mar 18, 2014 at 20:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.