Skip to content

Instantly share code, notes, and snippets.

@geog4046instructor
Last active January 1, 2018 22:59
Show Gist options
  • Save geog4046instructor/0f53749488274a1796d2 to your computer and use it in GitHub Desktop.
Save geog4046instructor/0f53749488274a1796d2 to your computer and use it in GitHub Desktop.
ArcGIS JavaScript API - add a layer
/* Add layer(s) from an ArcGIS web service
*
* function name: ArcGISDynamicMapServiceLayer
* module name: "esri/layers/ArcGISDynamicMapServiceLayer"
* documentation: https://developers.arcgis.com/javascript/jssamples/map_dynamic.html
* example: http://developers.arcgis.com/javascript/samples/map_dynamic/
*/
// Create a layer object from an ArcGIS Server web service, with no options
let layer1 = new ArcGISDynamicMapServiceLayer( "http://example.com/arcgis/rest/services/Layer1/MapServer" );
map.addLayer(layer1); // add the layer object to the map
// Create a layer object from an ArcGIS Server web service, setting the opacity option
let layer2 = new ArcGISDynamicMapServiceLayer( "http://example.com/arcgis/rest/services/Layer2/MapServer", {
"opacity": 0.35
});
map.addLayer(layer2); // add the layer object to the map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment