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);
推薦閱讀
- C++面向對象程序設計(第三版)
- DBA攻堅指南:左手Oracle,右手MySQL
- 垃圾回收的算法與實現
- Rust編程:入門、實戰與進階
- Instant Zepto.js
- MATLAB 2020 從入門到精通
- Full-Stack React Projects
- Python機器學習算法與實戰
- Getting Started with LLVM Core Libraries
- 從零開始學C#
- Python深度學習原理、算法與案例
- Hands-On Kubernetes on Windows
- Troubleshooting Citrix XenApp?
- Learning Bootstrap 4(Second Edition)
- 寫給青少年的人工智能(Python版·微課視頻版)