- Building Web and Mobile ArcGIS Server Applications with JavaScript(Second Edition)
- Eric Pimpler Mark Lewin
- 126字
- 2021-07-02 15:49:00
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);
推薦閱讀
- 程序員面試筆試寶典(第3版)
- Hyper-V 2016 Best Practices
- FreeSWITCH 1.8
- CentOS 7 Server Deployment Cookbook
- Three.js開發指南:基于WebGL和HTML5在網頁上渲染3D圖形和動畫(原書第3版)
- TestNG Beginner's Guide
- Getting Started with PowerShell
- SSM開發實戰教程(Spring+Spring MVC+MyBatis)
- C專家編程
- Unity 3D腳本編程:使用C#語言開發跨平臺游戲
- Unity&VR游戲美術設計實戰
- Visual Studio Code 權威指南
- Getting Started with Polymer
- Java編程從入門到精通
- Learning Unreal Engine Game Development