2

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.

1 Answer 1

3

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>
1
  • 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
    Commented Nov 18, 2014 at 14:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.