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

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);
主站蜘蛛池模板: 广宗县| 南投县| 祁阳县| 通许县| 竹山县| 岳阳市| 资源县| 富裕县| 静乐县| 普安县| 安新县| 滕州市| 富民县| 田阳县| 宝坻区| 苏尼特左旗| 吴忠市| 新沂市| 太白县| 桦川县| 巫溪县| 汶川县| 合水县| 阜平县| 库伦旗| 屏山县| 祥云县| 出国| 浮山县| 皋兰县| 吴堡县| 镇赉县| 嵊州市| 海安县| 信丰县| 扶余县| 新营市| 稻城县| 长武县| 莆田市| 金川县|