Hello,
I am looking for an idea about how to define the map so the users can only move inside of a specific extent. I want the users to be able to pan, scroll and generally move inside the box, but I don’t want them to move outside of the box.
Any idea?
Thank you Roi Algavish.
Roi,
maybe you could use the extent-change event to check if the user is still in the extent you want them too and once they go outside your extent you can call a function that moves them back into the extent?
Map | API Reference | ArcGIS API for JavaScript
Tim
Hello,
Thank you for the response, I have done what you have suggested with this code:
app.map.on("extent-change", function(){
var geo = app.map.extent;
if (((geo.xmin) < (initialExtent.xmin - 100)) || ((geo.xmax) > (initialExtent.xmax + 100)) || ((geo.ymax) > (initialExtent.ymax + 100)) || ((geo.ymin) < (initialExtent.ymin - 100))){
app.map.setExtent(initialExtent)
}})
No matter how many different version of how to write it, all the times I have tried it the code worked, but about 50% of the time in chrome (in Firefox more than that), after some paning and zooming with the map it got stuck inside of re- centring the map.
Any idea?
Thank You,
Roi.