官术网_书友最值得收藏!

Setting the visible layers from a map service

You can control the visibility of individual layers within a dynamic map service layer using the setVisibleLayers() method. This only applies to dynamic map service layers, not tiled map service layers. This method takes an array of integers corresponding to the data layers in the map service. This array is zero-based so the first layer in the map service occupies position 0. In the Demographics map service illustrated in the following screenshot, Demographics/ESRI_Census_USA (0) occupies index 0:

Therefore, in the event that we'd like to display only the Census Block Points and Census Block Groups from this service we could use setVisibleLayers() as seen in the code example as follows:

var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com
/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"); dynamicMapServiceLayer.setVisibleLayers([0,1]); map.addLayer(dynamicMapServiceLayer);
主站蜘蛛池模板: 焦作市| 民和| 衢州市| 乐业县| 寻乌县| 浦东新区| 南投县| 运城市| 靖远县| 新乡县| 枣阳市| 正宁县| 古蔺县| 白玉县| 青海省| 峨边| 东乌珠穆沁旗| 宾阳县| 含山县| 德清县| 芜湖市| 嘉荫县| 开远市| 柳州市| 长乐市| 滦南县| 安龙县| 雅安市| 商河县| 永济市| 宣威市| 鹰潭市| 金堂县| 闽清县| 西充县| 临安市| 云龙县| 屯昌县| 双辽市| 陆川县| 久治县|