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

Dynamic map service layers

As the name suggests, the ArcGISDynamicMapServiceLayer class is used to create dynamic maps served by ArcGIS Server, where all the of map imagery is rendered on the fly.

Just like the ArcGISTiledMapServiceLayer, the ArcGISDynamicMapServiceLayer constructor takes a URL endpoint for the map service along with optional parameters used to assign an ID to the service, specify the transparency of the map image, or set the initial visibility of the layer on or off:

The class name ArcGISDynamicMapServiceLayer can be somewhat misleading. Although it appears to reference an individual data layer this is in fact not the case. It refers to a map service rather than a data layer. Individual layers inside the map service can be turned on/off through the class setVisibleLayers() method.

The code for creating an instance of ArcGISDynamicMapServiceLayer looks very similar to the code for working with ArcGISTiledMapServiceLayer, as can be seen as follows.

The constructor accepts a URL for the map service endpoint. The second parameter accepts an options object that you can supply to control transparency, visibility, and image parameters:

var operationalLayer = new ArcGISDynamicMapServiceLayer("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer",{"opacity":0.5}); 
map.addLayer(operationalLayer); 

Add the preceding two lines of code to the ArcGIS API for JavaScript Sandbox, under the line of code that creates the map. Also ensure that you reference esri/layers/ArcGISDynamicMapServiceLayer in the require() function:

require(["esri/map", "esri/layers/ArcGISDynamicMapServiceLayer", "dojo/domReady!"],
function(Map, ArcGISDynamicMapServiceLayer) {
map = new Map("map", {
basemap: "topo",
center: [-122.19, 37.94], // longitude, latitude
zoom: 6
});
var operationalLayer = new ArcGISDynamicMapServiceLayer("https://sampleserver1.arcgisonline.com
ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer",{"opacity":0.5});
map.addLayer(operationalLayer);
});

Click the Refresh button in the Sandbox to see the dynamic layer added to the map as shown in the following screenshot:

With an instance of ArcGISDynamicMapServiceLayer you can perform a number of operations. Obviously you can create maps that display the data in the service, but you can also query data from layers in the service, control feature display through layer definitions, control individual layer visibility, display temporal information, export maps as images, control background transparency, and more.

主站蜘蛛池模板: 西畴县| 正阳县| 巧家县| 阿克陶县| 景洪市| 嘉善县| 高尔夫| 关岭| 巴塘县| 宜黄县| 曲沃县| 陇南市| 武清区| 贵阳市| 廊坊市| 潮州市| 清水县| 徐汇区| 贵州省| 澄江县| 永吉县| 成武县| 玉林市| 安顺市| 五指山市| 拉萨市| 泸水县| 崇明县| 溧水县| 彭阳县| 民丰县| 墨竹工卡县| 横山县| 皮山县| 鹤峰县| 池州市| 逊克县| 鸡东县| 额济纳旗| 固安县| 吉安县|