1. 矢量动态图层

 

ArcGIS JavaScript API动态图层_html

 

<!DOCTYPEHTML>

<html>

 

<head>

<metahttp-equiv="Content-Type"content="text/html; charset=utf-8"/>

<title>Test Map</title>

<linkrel="stylesheet"href="http://172.16.2.17:8080/arcgis_js_api/library/3.26/3.26/esri/css/esri.css"/>

<scripttype="text/javascript">

vararcgisApiBaseUrl = "http://172.16.2.17:8080/arcgis_js_api/library/3.26/3.26";

</script>

<scriptsrc="http://172.16.2.17:8080/arcgis_js_api/library/3.26/3.26/init.js"></script>

<style>

html,

body,

#map {

height: 100%;

width: 100%;

margin: 0;

padding: 0;

}

</style>

<script>

require([

"esri/config",

"esri/map",

"esri/layers/ArcGISDynamicMapServiceLayer",

"esri/layers/ArcGISTiledMapServiceLayer",

"esri/layers/DynamicLayerInfo",

"esri/layers/LayerDataSource",

"esri/layers/TableDataSource",

"esri/layers/LayerDrawingOptions",

"esri/renderers/SimpleRenderer",

"esri/symbols/SimpleFillSymbol",

"esri/symbols/SimpleLineSymbol",

"esri/Color",

"dojo/domReady!"

], function (esriConfig, Map, ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer, DynamicLayerInfo,

LayerDataSource, TableDataSource, LayerDrawingOptions, SimpleRenderer, SimpleFillSymbol, SimpleLineSymbol,

Color) {

//esri.config.defaults.io.corsDetection=false;

//esri.config.defaults.io.corsEnabledServers.push("172.16.4.249:8080");

varmap = newMap("map");

//var tiled = new ArcGISTiledMapServiceLayer("https://services.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer");

//map.addLayer(tiled);

//

varshengLayer = newesri.layers.ArcGISDynamicMapServiceLayer(

"http://172.16.2.17:6080/arcgis/rest/services/resourceAudit/DynamicLayer/MapServer", {

"id":"mymaplayer"

})

map.addLayer(shengLayer);

//

 

functionAddDynamicLayer1() {

 

varlayerName, dataSource, layerSource, options, drawingOptions, dynamicLayerInfos;

 

layerName = "region";

if (!dynamicLayerInfos) {

dynamicLayerInfos = map.getLayer("mymaplayer").createDynamicLayerInfosFromLayerInfos();

}

console.log(dynamicLayerInfos.length);

//

dataSource = newesri.layers.TableDataSource();

dataSource.workspaceId = "resourceAudit";

dataSource.dataSourceName = layerName;

//

layerSource = newesri.layers.LayerDataSource();

layerSource.dataSource = dataSource;

//

vardynamicLayerInfo = newesri.layers.DynamicLayerInfo({

"defaultVisibility":true,

"id":dynamicLayerInfos.length,

"name":layerName,

"parentLayerId": -1,

"source":layerSource

});

//dynamicLayerInfos.push(dynamicLayerInfo); // 最后一个图层

dynamicLayerInfos.unshift(dynamicLayerInfo) // 第一个图层

// set new infos, but don't refresh

// map will be updated when the drawing options are set

map.getLayer("mymaplayer").setDynamicLayerInfos(dynamicLayerInfos, true);

 

drawingOptions = newesri.layers.LayerDrawingOptions();

drawingOptions.renderer = newesri.renderer.SimpleRenderer(

newesri.symbol.SimpleFillSymbol("solid", newesri.symbol.SimpleLineSymbol("solid", newdojo.Color([255,

0, 255, 0.75

]), 5),

newdojo.Color([255, 0, 255, 0.75]) // fuchsia lakes!

));

options = [];

options[dynamicLayerInfos.length - 1] = drawingOptions;

map.getLayer("mymaplayer").setLayerDrawingOptions(options);

 

}

shengLayer.on("load", function (e) {

AddDynamicLayer1();

});

});

//

//

</script>

</head>

 

<body>

<divid="map"></div>

</body>

 

</html>

 

添加到最上面

ArcGIS JavaScript API动态图层_ico_02

 

 

添加到最后面

 

ArcGIS JavaScript API动态图层_html_03

 

  1. 栅格动态图层

 

ArcGIS JavaScript API动态图层_ico_04