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

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);
主站蜘蛛池模板: 阿城市| 南部县| 托克托县| 嘉鱼县| 广西| 柳林县| 阜新| 长阳| 新宁县| 衡山县| 宁安市| 都昌县| 婺源县| 博野县| 昭通市| 平泉县| 白河县| 元阳县| 江西省| 嘉峪关市| 肥城市| 麻阳| 射阳县| 华蓥市| 文成县| 宝兴县| 山阳县| 丰台区| 潢川县| 江门市| 泸州市| 建昌县| 镇平县| 陆良县| 布拖县| 达日县| 武功县| 合水县| 大城县| 弥渡县| 邢台县|