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

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

主站蜘蛛池模板: 崇明县| 大竹县| 汤阴县| 普兰店市| 崇左市| 新沂市| 清河县| 弥渡县| 益阳市| 高平市| 陕西省| 全椒县| 太和县| 岢岚县| 平山县| 墨玉县| 清远市| 平定县| 丹棱县| 额济纳旗| 西乡县| 三明市| 彰武县| 淳化县| 苍南县| 张家界市| 巴塘县| 乐亭县| 云和县| 岳阳市| 巩留县| 莱芜市| 加查县| 宁陕县| 苗栗县| 虞城县| 吐鲁番市| 休宁县| 祁东县| 施秉县| 凤庆县|