redirect | title | layout |
---|---|---|
L.esri.DynamicMapLayer |
documentation.hbs |
Extends L.esri.RasterLayer
Render and visualize Map Services from ArcGIS Enterprise. L.esri.DynamicMapLayer
also supports custom popups and identification of features.
Map Services are used when its preferable to ask the server to draw layers and pass back the image which was generated on the fly instead of attempting to render client-side graphics. It is possible to control which specific layers from the Map Service are displayed using the layers
constructor option.
Map Service urls do not end in a number.
https://sampleserver6.arcgisonline.com/arcgis/rest/services/Hurricanes/MapServer/
Constructor | Description |
---|---|
L.esri.dynamicMapLayer({{{param 'Object' 'options'}}}) | The options parameter can accept the same options as L.ImageOverlay .Passing a url is mandatory. |
Option | Type | Default | Description |
---|---|---|---|
url |
String |
Required URL of the Map Service. | |
format |
String |
'png24' |
Output format of the image. |
transparent |
Boolean |
true |
Allow the server to produce transparent images. |
f |
String |
'json' |
Server response content type "json" | "image" . |
attribution |
String |
Attribution from service metadata copyright text is automatically displayed in Leaflet's default control. This property can be used for customization. | |
layers |
Array |
An array of Layer IDs like [3,4,5] to show from the service. |
|
layerDefs |
Object |
SQL filters to define what features will be included in the image rendered by the service. An object is used with keys that map each query to its respective layer. { 3: "STATE_NAME='Kansas'", 9: "POP2007>25000" } |
|
opacity |
Number |
1 |
Opacity of the layer. Should be a value between 0 (completely transparent) and 1 (completely opaque). |
pane |
String |
overlayPane |
The map pane to render on. This is the preferred technique to control draw order in Leaflet 1.x. |
zIndex |
Number |
Used to refine draw order further (within a map pane). | |
position |
String |
'front' |
Legacy option to control draw order. For best results, use pane . |
maxZoom |
Number |
Closest zoom level the layer will be displayed on the map. | |
minZoom |
Number |
Furthest zoom level the layer will be displayed on the map. | |
dynamicLayers |
[Object] |
Array of one or more JSON objects used to override the layer symbology defined by the service. Requires a 10.1+ map service which supports dynamicLayers requests. | |
disableCache |
Boolean |
If enabled, appends a timestamp to each request to ensure a fresh image is created server-side. | |
token |
String |
If you pass a token in your options it will be included in all requests to the service. | |
proxy |
String |
false |
URL of an ArcGIS API for JavaScript proxy or ArcGIS Resource Proxy to use for proxying POST requests. |
useCors |
Boolean |
true |
If this service should use CORS when making GET requests. |
popup |
Object |
Instance of IdentifyFeatures to allow for more fine-grained control over the /identify request triggered by 'bindPopup()'. |
|
to |
Date |
Used to filter the features displayed in the service based on a time range. | |
from |
Date |
Used to filter the features displayed in the service based on a time range. |
Method | Returns | Description |
---|---|---|
bringToBack() |
this |
Redraws this layer below all other overlay layers. |
bringToFront() |
this |
Redraws this layer above all other overlay layers. |
bindPopup({{{param 'Function' 'fn'}}}, {{{param 'PopupOptions' 'popupOptions' 'https://leafletjs.com/reference.html#popup-options'}}}) |
this |
Uses the provided function to create a popup that will identify features whenever the map is clicked. Your function will be passed a GeoJSON FeatureCollection of the features at the clicked location and should return the appropriate HTML. If you do not want to open the popup when there are no results, return false .
|
unbindPopup() |
this |
Removes a popup previously bound with bindPopup . |
getOpacity() |
Float |
Returns the current opacity of the layer. |
setOpacity({{{param 'Float' 'opacity'}}}) |
this |
Sets the opacity of the layer. |
getLayers() |
Array |
Returns the array of visible layers specified in the layer constructor. |
setLayers({{{param 'Array' 'layers'}}}) |
this |
Redraws the layer to show the passed array of layer ids. |
getLayerDefs() |
Object |
Returns the current layer definition(s) being used for rendering. |
setLayerDefs({{{param 'Object' 'layerDefs' 'https://developers.arcgis.com/rest/services-reference/export-map.htm'}}}) |
this |
Redraws the layer with the new layer definitions. Corresponds to the layerDefs option on the export API. |
getTimeRange() |
Array |
Returns the current time range being used for rendering. |
setTimeRange({{{param 'Date' 'from'}}}, {{{param 'Date' 'to'}}}) |
this |
Redraws the layer with he passed time range. |
getTimeOptions() |
Object |
Returns the current time options being used for rendering. |
setTimeOptions({{{param 'Object' 'timeOptions' 'https://developers.arcgis.com/rest/services-reference/export-map.htm'}}}) |
this |
Sets the current time options being used to render individual layers. Corresponds to the layerTimeOptions option on the export API. |
getDynamicLayers() |
[Object] |
Returns an array of JSON objects representing the modified layer symbology being requested from the map service. |
setDynamicLayers({{{param 'Array' 'dynamicLayers' 'https://developers.arcgis.com/rest/services-reference/export-map.htm' }}}) |
this |
Used to insert raw dynamicLayers JSON in array form in situations where you'd like to modify layer symbology defined in the service itself.
|
metadata({{{param 'Function' 'callback'}}}, {{{param 'Object' 'context'}}}) |
this |
Requests metadata about this Feature Layer. Callback will be called with `error` and `metadata`.
|
authenticate({{{param 'String' 'token'}}}) |
this |
Authenticates this service with a new token and runs any pending requests that required a token. |
identify() |
this |
Returns a new L.esri.services.IdentifyFeatures object that can be used to identify features on this layer. Your callback function will be passed a GeoJSON FeatureCollection with the results or an error.
|
find() |
this |
Returns a new L.esri.services.Find object that can be used to find features. Your callback function will be passed a GeoJSON FeatureCollection with the results or an error.
|
query() |
this |
Returns a new L.esri.Query object that can be used to query this service.
|
redraw() |
Used to make a fresh request to the service and draw the response. |
Event | Data | Description |
---|---|---|
loading |
<LoadingEvent > |
Fires when new features start loading. |
load |
<LoadEvent > |
Fires when all features in the current bounds of the map have loaded. |
L.esri.DynamicMapLayer
also fires all L.esri.MapService
events.
var map = L.map('map').setView([38.83, -98.5], 7);
L.esri.basemapLayer('Gray').addTo(map);
var url = 'https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Petroleum/KGS_OilGasFields_Kansas/MapServer';
L.esri.dynamicMapLayer({
url: url,
opacity: 0.25,
useCors: false
}).addTo(map);