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

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

主站蜘蛛池模板: 平武县| 汕尾市| 合川市| 洛南县| 邢台市| 若羌县| 宜兰市| 高陵县| 龙州县| 凤阳县| 贵州省| 大新县| 沧源| 红河县| 瑞金市| 清苑县| 石渠县| 襄垣县| 凤冈县| 香格里拉县| 大石桥市| 上林县| 承德市| 东乌珠穆沁旗| 环江| 泗阳县| 襄垣县| 灵宝市| 恩施市| 自贡市| 大关县| 灵台县| 南皮县| 吉木萨尔县| 铜山县| 四子王旗| 张家口市| 城市| 五峰| 治多县| 宝鸡市|