Here is my code for my map:
omap = new Map("overviewMap", { extent: initExtent, logo: false, slider: false });
tmoverview = new ArcGISDynamicMapServiceLayer(mylayer, { "opacity": 1.0, "visible": true });
omap.addLayer(tmoverview);
omap.disableMapNavigation();
omap.disableKeyboardNavigation();
omap.disablePan();
omap.disableRubberBandZoom();
omap.disableScrollWheelZoom();
Yet, when I run it, the map navigation is NOT disabled, the keyboard navigation is NOT disabled, the pan is NOT disabled, the rubber band zoom is NOT disabled, and the scroll wheel also continues to operate. Please tell me how to disable all of this functionality in my web map.
asked Nov 13, 2014 at 18:56
1 Answer 1
You have to wait until the map is ready to have those methods attached to it.
This disables the navigation.
<!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>Simple Map</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.11/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body {
background-color: #FFF;
overflow: hidden;
font-family: "Trebuchet MS";
}
</style>
<script src="http://js.arcgis.com/3.11/"></script>
<script>
var map;
require(["esri/map", "dojo/domReady!"], function(Map) {
map = new Map("map", {
basemap: "topo",
center: [-122.45, 37.75], // longitude, latitude
zoom: 13
});
map.on("load", function(){
console.log("Map loaded");
map.disableMapNavigation();
map.disableKeyboardNavigation();
map.disablePan();
map.disableRubberBandZoom();
map.disableScrollWheelZoom();
});
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
answered Nov 13, 2014 at 19:12
-
Actually I found I had to late-bind the map anyway (because of differences in browsers) and in that case the code I provided actually worked.brenth– brenth2014年11月18日 14:27:32 +00:00Commented Nov 18, 2014 at 14:27
lang-js