1

The below code works to get the current zoom level in ArcGIS 3.18 JavaScript API.

<!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.18/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.18/"></script>
<script>
  var map;
  require(["esri/map", "dojo/domReady!"], function(Map) {
    map = new Map("map", {
      basemap: "topo",  //For full list of pre-defined basemaps, navigate to http://arcg.is/1JVo6Wd
      center: [-122.45, 37.75], // longitude, latitude
      zoom: 13
    });
    map.on("extent-change",function(evt)
      {
        console.log("extent change",map.getZoom());
        if(map.getZoom() > 13)
          map.setZoom(13);
      }
    );
  });
</script>

But map.getZoom() or map.setZoom() is not a method in the ArcGIS 4.0 JavaScript API MAP Class.

How do I get the current zoom level in ArcGIS 4.0 map JavaScript?

0

1 Answer 1

1

I solved it with MapView.zoom property.

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.