Adding layers to the map
The Map.addLayer() method takes an instance of a layer (ArcGISDynamicMapServiceLayer or ArcGISTiledMapServiceLayer in our examples) as the first parameter, and an optional index that specifies where it should be placed. If you don't specify an index, the layer will be placed on top of all the other layers in the map, which is often what you want so that you can be sure it is visible.
In the following code example we create a new instance of ArcGISDynamicMapServiceLayer. We then call Map.addLayer(), passing in the new instance of the layer. The layers in the service will now be visible on the map:
var operationalLayer = new ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer"); map.addLayer(operationalLayer);
If you want to add more than one layer to the map in one go, you can use Map.addLayers(), which accepts an array of layer objects.
As well as being able to add layers to a map you can also remove them by using Map.removeLayer(layer) or Map.removeAllLayers().
- 復雜軟件設計之道:領域驅動設計全面解析與實戰
- 無代碼編程:用云表搭建企業數字化管理平臺
- 架構不再難(全5冊)
- Visual Basic程序設計教程
- Data Analysis with IBM SPSS Statistics
- Instant RubyMotion App Development
- Python漫游數學王國:高等數學、線性代數、數理統計及運籌學
- C#程序設計
- Jupyter數據科學實戰
- C語言程序設計同步訓練與上機指導(第三版)
- Mastering Unity 2D Game Development(Second Edition)
- Mastering Linux Security and Hardening
- RESTful Java Web Services(Second Edition)
- JQuery風暴:完美用戶體驗
- Python預測分析與機器學習