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

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().

主站蜘蛛池模板: 大城县| 阜宁县| 崇明县| 来宾市| 镇平县| 南京市| 德清县| 海淀区| 灵川县| 沅江市| 乐陵市| 海伦市| 修水县| 新绛县| 扎兰屯市| 都昌县| 平江县| 大关县| 丽水市| 灌南县| 博客| 卢龙县| 富蕴县| 简阳市| 洪湖市| 黎川县| 前郭尔| 广河县| 含山县| 育儿| 全州县| 沁源县| 周口市| 黄石市| 易门县| 娄底市| 河南省| SHOW| 牟定县| 诏安县| 亚东县|