Select to view content in your preferred language

Use event ZOOM of MAP API

5871
3
01-25-2015 08:17 PM
lasinh
by
Occasional Contributor

how to alert(" this is my Map") when zoom my map

myMap.zoom()

{

alert(" this is my Map");

}

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

La Sinh,

myMap.on("zoom-end", function(){

    alert("this is my Map");

});

0 Kudos
KenBuja
MVP Esteemed Contributor

Do you really need to require "dojo/on" to do this? Isn't that only necessary if you want to use the extra event handling methods (pause, once, etc.)?

<!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.12/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.12/"></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("zoom-end", function (){
          console.log("zoom finished!");
        });
      });
    </script>
  </head>

  <body>
    <div id="map"></div>
  </body>
</html>
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Good point Ken. Post edited.

0 Kudos