Is there any way using JavaScript API to get the current "displayLevels" of the basemap or "basemap zoom level" or "basemap scale" of the map and if it was more/less than certain number I change the Layer to another layer?


map = new Map("map", {
           basemap: "topo",
           center: [-85.416, 49.781],
           zoom : 5,
           logo: false});
if (map zoom level == ***) {

 layer1 = new FeatureLayer(
                "http://testServer/arcgis/rest/services/test/MapServer/0", {
                        mode: FeatureLayer.MODE_ONDEMAND


else {
layer2 = new FeatureLayer(
                "http://testServer/arcgis/rest/services/test/MapServer/1", {
                        mode: FeatureLayer.MODE_ONDEMAND


  • how to get current zoom level in arcgis 4.0 map javascript.. map.getLevel() is not a method arcGis 4.0 API MAP Class...please tell me how to get current zoom level in arcGis 4.0 Map – user83058 Sep 22 '16 at 13:42
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – Evil Genius Sep 22 '16 at 14:15

Map has the property getLevel which you can use to find the zoom level.

<!DOCTYPE html>
    <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.7/js/esri/css/esri.css">
      html, body, #map {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      body {
        background-color: #FFF;
        overflow: hidden;
        font-family: "Trebuchet MS";
    <script src="http://js.arcgis.com/3.7/"></script>
    var map;

    require(["esri/map", "dojo/domReady!"], function(Map) {
        map = new Map("map", {
          basemap: "topo",
          center: [-122.45,37.75], // long, lat
          zoom: 13,
          sliderStyle: "small"

        map.on("extent-change", function(){console.log(map.getLevel());})

    <div id="map"></div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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