- 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);
推薦閱讀
- Beginning Java Data Structures and Algorithms
- 認識編程:以Python語言講透編程的本質
- 營銷數據科學:用R和Python進行預測分析的建模技術
- 網絡爬蟲原理與實踐:基于C#語言
- Access 2010中文版項目教程
- 硬件產品設計與開發:從原型到交付
- Mastering SciPy
- Python程序設計教程
- Java編程指南:語法基礎、面向對象、函數式編程與項目實戰
- Building Microservices with Go
- Learning Perforce SCM
- IBM DB2 9.7 Advanced Application Developer Cookbook
- Vue.js項目開發實戰
- Python程序設計教程
- Developing Multi:Platform Apps with Visual Studio Code