L.esri.Layers.DynamicMapLayer
Render and visualize Map Services from ArcGIS Online and ArcGIS Server. L.esri.Layers.DynamicMapLayer also supports custom popups and identification of features.
Map Servers are a way to expose the contents that make up a map as a web service and can expose different capabilites for exporting tiles images, querying and identifying features and more.
Constructor
Constructor | Description |
---|---|
new L.esri.Layers.DynamicMapLayer( L.esri.Layers.dynamicMapLayer( new L.esri.DynamicMapLayer( L.esri.dynamicMapLayer( |
url should be the URL to the Map Service hosted the tiles. The options parameter can accept the same options as L.TileLayer |
Options
L.esri.DynamicMapLayer
also accepts all the options you can pass to L.ImageOverlay
.
Option | Type | Default | Description |
---|---|---|---|
format |
String |
'png24' |
Output format of the image. |
transparent |
Boolean |
true |
Allow the server to produce transparent images. |
f |
String |
'image' |
Server response content type. |
bboxSR |
Integer |
4326 |
Spatial reference of the bounding box to generate the image with. If you don't know what this is don't change it. |
imageSR |
Integer |
3857 |
Spatial reference of the output image. If you don't know what this is don't change it. |
layers |
Array |
'' |
An array of Layer IDs like [3,4,5] to show from the service. |
layerDefs |
String Object |
'' |
A string representing a query to run against the service before the image is rendered. This can be a string like "STATE_NAME='Kansas' and POP2007>25000" or an object mapping different queries to specific layers {5:"STATE_NAME='Kansas'", 4:"STATE_NAME='Kansas'} . |
opacity |
Number |
1 |
Opacity of the layer. Should be a value between 0 and 1. |
position |
String |
'front' |
Position of the layer relative to other overlays. |
token |
String |
null |
If you pass a token in your options it will included in all requests to the service. See working with authenticated services for more information. |
proxy |
String |
false |
URL of an ArcGIS API for JavaScript proxies or ArcGIS Resource Proxies to use for proxying POST requests. |
useCors |
Boolean |
true |
If this service should use CORS when making GET requests. |
Methods
Method | Returns | Description |
---|---|---|
bringToBack() |
this |
Redraws this layer below all other overlay layers. |
bringToFront() |
this |
Redraws this layer above all other overlay layers. |
bindPopup( |
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( |
this |
Sets the opacity of the layer. |
getLayers() |
Array |
Returns the array of layers on the MapService that are being shown. |
setLayers( |
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( |
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( |
this |
Redraws the layer with he passed time range. |
getTimeOptions() |
Object |
Returns the current time options being used for rendering. |
setTimeOptions( |
this |
Sets the current time options being used to render the layer. Corresponds to the layerTimeOptions option on the export API. |
metadata( |
this |
Requests metadata about this Feature Layer. Callback will be called with error and metadata .
|
authenticate( |
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.Tasks.Query object that can be used to query this service.
|
Events
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.Layer.DynamicMapLayer
also fires all L.esri.Service.MapService
events.
Example
var map = L.map('map').setView([ 38.83,-98.5], 7);
L.esri.basemapLayer('Gray').addTo(map);
var url = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Petroleum/KGS_OilGasFields_Kansas/MapServer";
L.esri.dynamicMapLayer(url, {
opacity : 0.25
}).addTo(map);
Esri Leaflet is a project from the Esri PDX R&D Center and the Esri Community