<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>map.disablePan doesn't work immediately.</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.7/js/esri/css/esri.css"/>
<style>
html,body,#mapDiv{
padding:0;
margin:0;
height:100%;
}
#dvBind{
position:absolute;
background:rgb(220,220,220);
cursor:pointer;
z-index:2;
left:100px;
top:100px;
}
</style>
<script src="http://js.arcgis.com/3.7/"></script>
<script>
dojo.require("esri.map");
var map;
var mouseOutHandler=null;
dojo.ready(function(){
//create map and add a dynamic layer
map = new esri.Map("mapDiv");
var imageParameters = new esri.layers.ImageParameters();
imageParameters.format = "jpeg";
var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer", {
"opacity":0.5,
"imageParameters":imageParameters
});
map.addLayer(dynamicMapServiceLayer);
//bind UI events.
document.getElementById("dvBind").onclick=function(){
if(mouseOutHandler==null){
console.log("map.mouseOut is binded");
mouseOutHandler= dojo.connect(map,"onMouseOut",function(){
map.disablePan();
console.log("map.onMouseOut is triggered. map.disablePan() is executed. However, if the left button is not released, pan the map at your will!");
console.log("If you know any way to STOP PAN IMMEDIATELY, leave a message, Thank you!");
});
}
};
});
</script>
</head>
<body>
<div id="dvBind" title="Click me to bind map.onMouseOut">Bind map.onMouseOut</div>
<div id="mapDiv"></div>
</body>
</html>
Hey,
I don't know if you already have found a solution for your problem or not. So I would like to share my solution with you.
To stop map pan immediatly you can do this:
var map = new Map(args);
map.on("mouse-out", function(evt)
{
map.navigationManger._panEnd(); // disconnects all pan handles.
});The lower dash indeed indicates that the method is private..., anyway it works like a charm! 😃