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?

nmtoken
13.6k5 gold badges39 silver badges91 bronze badges
asked Dec 27, 2016 at 21:36
0

1 Answer 1

1

I solved it with MapView.zoom property.

answered Jan 3, 2017 at 21:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.