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

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);
主站蜘蛛池模板: 普定县| 高阳县| 廊坊市| 安平县| 武安市| 霍州市| 突泉县| 江城| 凤山县| 辰溪县| 万盛区| 白山市| 永胜县| 建宁县| 两当县| 彭州市| 正定县| 电白县| 台北市| 灵宝市| 台北市| 瑞安市| 蒲江县| 南召县| 通城县| 榕江县| 盘山县| 胶州市| 宜州市| 宁明县| 德钦县| 莎车县| 长春市| 鹤山市| 龙州县| 隆昌县| 永德县| 惠东县| 屏山县| 平山县| 北川|