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?
function(
Map,
FeatureLayer
){
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
});
map.addLayer(layer1);
}
else {
layer2 = new FeatureLayer(
"http://testServer/arcgis/rest/services/test/MapServer/1", {
mode: FeatureLayer.MODE_ONDEMAND
});
map.addLayer(layer2);
}
asked Nov 12, 2013 at 19:09
-
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 Mapuser83058– user830582016年09月22日 13:42:56 +00:00Commented Sep 22, 2016 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 ReviewEvil Genius– Evil Genius2016年09月22日 14:15:39 +00:00Commented Sep 22, 2016 at 14:15
1 Answer 1
Map has the property getLevel which you can use to find the zoom level.
<!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.7/js/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.7/"></script>
<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());})
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
answered Nov 12, 2013 at 19:26
Explore related questions
See similar questions with these tags.
lang-js