L.esri.Heat.FeatureLayer

Extends L.esri.Layers.FeatureLayer

L.esri.Heat.FeatureLayer provides integration for Feature Layers with the Leaflet.heat plugin. Because of the extra dependency on Leaflet.heat we do not include L.esri.Heat.FeatureLayer in the default build of Esri Leaflet. You will need to include your own copy of the Leaflet.heat plugin in your application as well.

More information about Feature Layers can be found in the L.esri.FeatureLayer documentation. You can find more information and the source code for this plugin here.

Constructor

ConstructorDescription
L.esri.Heat.featureLayer(<Object> options)You must pass a url to a Feature Layer in your options

Options

OptionTypeDescription
urlStringRequired The URL to the Feature Layer.
whereStringA server side expression that will be evaluated to filter features. By default this will include all features in a service.
fieldsArrayAn array of fieldnames to pull from the service. Includes all fields by default. You should always specify the name of the unique id for the service. Usually either 'FID' or 'OBJECTID'.
fromDateWhen paired with to defines the time range of features to display. Requires the Feature Layer to be time enabled.
toDateWhen paired with from defines the time range of features to display. Requires the Feature Layer to be time enabled.
timeFieldfalseThe name of the field to lookup the time of the feature. Can be an object like start:'startTime', end:'endTime' or a string like 'created'.
timeFilterMode'server' (default) or 'client'Determines where features are filtered by time. By default features will be filtered by the server. If set to 'client' all features are requested and filtered by the app before display.
precisionIntegerHow many digits of geometry precision to request from the server. Wikipedia has a great reference of digit precision to meters.
tokenStringIf you pass a token in your options it will be included in all requests to the service.
proxyStringURL of an ArcGIS API for JavaScript proxies or ArcGIS Resource Proxies to use for proxying POST requests.
useCorsBooleanIf this service should use CORS when making GET requests.

L.esri.Heat.FeatureLayer will also accept any options that can be passed to Leaflet.heat to customize the appearance of the heatmap.

Events

EventTypeDescription
loading<LoadingEvent>Fires when new features start loading.
load<Load>Fires when all features in the current bounds of the map have loaded.

L.esri.Heat.FeatureLayer also fires all L.esri.FeatureLayerService events.

Methods

MethodReturnsDescription
getWhere()StringReturns the current where setting
setWhere(<String> where, <Function> callback, <Object> context)thisSets the new where option and refreshes the layer to reflect the new where filter. Accepts an optional callback and function context.
getTimeRange()ArrayReturns the current time range as an array like [from, to]
setTimeRange(<Date> from, <Date> to, , <Function> callback, <Object> context)thisSets the current time filter applied to features. An optional callback is run upon completion if timeFilterMode is set to 'server'. Also accepts function context as the last argument.
authenticate(<String> token)thisAuthenticates this service with a new token and runs any pending requests that required a token.
query()this

Returns a new

L.esri.Query

object that can be used to query this layer. Your callback function will be passed a GeoJSON FeatureCollection with the results or an error.

featureLayer.query()
.within(latlngbounds)
.where("Direction = 'WEST'")
.run(function(error, featureCollection){
    console.log(featureCollection);
});
metadata(<Function> callback, <Object> context)this

Requests metadata about this Feature Layer. Callback will be called with error and metadata.

featureLayer.metadata(function(error, metadata){ console.log(metadata); });

addFeature(<GeoJSON Feature> feature, <Function> callback, <Object> context)this

Adds a new feature to the feature layer. this also adds the feature to the map if creation is successful.

  • Requires authentication as a user who has permission to edit the service in the portal or the user who created the service.
  • Requires the Create capability be enabled on the service. You can check if creation exists by checking the metadata of your service under capabilities in the metadata.
updateFeature(<GeoJSON Feature> feature, <Function> callback, <Object> context)this

Update the provided feature on the Feature Layer. This also updates the feature on the map.

  • Requires authentication as a user who has permission to edit the service in the portal or the user who created the service.
  • Requires the Update capability be enabled on the service. You can check if creation exists by checking the metadata of your service under capabilities in the metadata.
deleteFeature(<String or Integer> id, <Function> callback, <Object> context)this

Remove the feature with the provided id from the feature layer. This will also remove the feature from the map if it exists.

  • Requires authentication as a user who has permission to edit the service in the portal or the user who created the service.
  • Requires the Update capability be enabled on the service. You can check if creation exists by checking the metadata of your service under capabilities in the metadata.

Example

Live sample here.

Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
      const map = L.map("map", {
        maxZoom: 16 // the heatmap plugin needs some help understanding the map's maxZoom
      }).setView([41.759, -88.157], 12);

      L.esri.Vector.vectorBasemapLayer("arcgis/light-gray", {
        token: accessToken
      }).addTo(map);

      // new constructor syntax at 2.0.0
      L.esri.Heat.featureLayer({
        url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/CommunityAddressing/MapServer/0",
        radius: 10
      }).addTo(map);
Expand

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.