esri-leaflet
Version:
Leaflet plugins for consuming ArcGIS Online and ArcGIS Server services.
334 lines (301 loc) • 17.5 kB
HTML
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class="not-ie"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title>L.esri.Layers.HeatMapFeatureLayer | Esri Leaflet</title>
<meta name="description" content="Esri Leaflet">
<meta name="viewport" content="width=device-width">
<!--[if lt IE 9]>
<script src="//cdn.jsdelivr.net/html5shiv/3.7.2/html5shiv-printshiv.js"></script>
<![endif]-->
<!-- google fonts -->
<link href='//fonts.googleapis.com/css?family=Vollkorn:400italic,700italic,400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="//brick.a.ssl.fastly.net/Source+Code+Pro:300">
<link href='//fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<!-- stylesheet -->
<link rel="stylesheet" href="../../css/style.css">
<!-- leaflet -->
<link rel="stylesheet" href="//cdn.jsdelivr.net/leaflet/0.7.7/leaflet.css" />
<!-- require combined leaflet, esri leaflet and jsdelivr-rum -->
<script src="//cdn.jsdelivr.net/leaflet/0.7.7/leaflet.js"></script>
<!--script src="//cdn.jsdelivr.net/leaflet.esri/1.0.3/esri-leaflet.js"></script-->
<script src="../../js/esri-leaflet-src.js"></script>
<script src="//cdn.jsdelivr.net/jsdelivr-rum/latest/jsdelivr-rum.min.js"></script>
<!-- 'livereload' for development -->
<script src="//localhost:35729/livereload.js"></script>
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-44963317-3', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
</head>
<body>
<div class="page-content ">
<div class="container">
<a class="site-nav" href="../../" class="left logo">Esri Leaflet</a>
<nav class="right">
<a class="site-nav" href="../../examples/">Examples</a>
<a class="site-nav" href="../../api-reference/">API Reference</a>
<a class="site-nav" href="../../download/">Download</a>
<a class="site-nav" href="https://github.com/Esri/esri-leaflet">View on GitHub</a>
</nav>
</div>
<div id="background-map" class="background-map"></div>
<div class="container white">
<aside class="sidebar">
<h5>L.esri.Layers</h5>
<nav>
<a href="../../api-reference/layers/basemap-layer.html">BasemapLayer</a>
<a href="../../api-reference/layers/feature-layer.html">FeatureLayer</a>
<a href="../../api-reference/layers/tiled-map-layer.html">TiledMapLayer</a>
<a href="../../api-reference/layers/dynamic-map-layer.html">DynamicMapLayer</a>
<a href="../../api-reference/layers/image-map-layer.html">ImageMapLayer</a>
<a href="../../api-reference/layers/clustered-feature-layer.html">ClusteredFeatureLayer</a>
<a href="../../api-reference/layers/heatmap-feature-layer.html">HeatmapFeatureLayer</a>
</nav>
<h5>L.esri.Tasks</h5>
<nav>
<a href="../../api-reference/tasks/query.html">Query</a>
<a href="../../api-reference/tasks/find.html">Find</a>
<a href="../../api-reference/tasks/identify-features.html">Identify Features</a>
<a href="../../api-reference/tasks/identify-image.html">Identify Image</a>
<a href="../../api-reference/tasks/task.html">Task</a>
</nav>
<h5>Misc.</h5>
<nav>
<a href="../../api-reference/request.html">Request</a>
<a href="../../api-reference/util.html">Util</a>
<a href="../../api-reference/events.html">Events</a>
</nav>
<h5>Base Classes</h5>
<nav>
<a href="../../api-reference/services/image-service.html">ImageService</a>
<a href="../../api-reference/services/feature-layer.html">FeatureLayerService</a>
<a href="../../api-reference/services/map-service.html">MapService</a>
<a href="../../api-reference/services/service.html">Service</a>
</nav>
</aside>
<div class="main-content">
<h1 id="l-esri-layers-heatmapfeaturelayer">L.esri.Layers.HeatMapFeatureLayer</h1>
<p><code>L.esri.Layers.HeatMapFeatureLayer</code> provides integration for Feature Layers with the <a href="https://github.com/Leaflet/Leaflet.heat">Leaflet.heat plugin</a>. Because of the extra dependency on Leaflet.heat we do not include <code>L.esri.Layers.HeatMapFeatureLayer</code> in the default build of Esri Leaflet. It lives in /dist/extras/heatmap-feature-layer.js. You will also need to include your own copy of the <a href="https://github.com/Leaflet/Leaflet.heat">Leaflet.heat plugin</a>.</p>
<p>More information about Feature Layers can be found in the <a href="../../api-reference/layers/feature-layer.html"><code>L.esri.Layers.FeatureLayer</code> documentation</a>.</p>
<h3 id="constructor">Constructor</h3>
<table>
<thead>
<tr>
<th>Constructor</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="nobr">new L.esri.Layers.HeatmapFeatureLayer(<nobr class="param"><span><String></span> <code>url</code></nobr>, <nobr class="param"><span><Object></span> <code>options</code></nobr>)</code><br><br><code class="nobr">L.esri.Layers.heatmapFeatureLayer(<nobr class="param"><span><String></span> <code>url</code></nobr>, <nobr class="param"><span><Object></span> <code>options</code></nobr>)</code><br><br><code class="nobr">new L.esri.HeatmapFeatureLayer(<nobr class="param"><span><String></span> <code>url</code></nobr>, <nobr class="param"><span><Object></span> <code>options</code></nobr>)</code><br><br><code class="nobr">L.esri.heatmapFeatureLayer(<nobr class="param"><span><String></span> <code>url</code></nobr>, <nobr class="param"><span><Object></span> <code>options</code></nobr>)</code></td>
<td><code>url</code> should be the URL to the Feature Layer.</td>
</tr>
</tbody>
</table>
### Options
<table>
<thead>
<tr>
<th>Option</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>where</code></td>
<td><code>String</code></td>
<td>A server side expression that will be evaluated to filter features. By default this will include all features in a service.</td>
</tr>
<tr>
<td><code>fields</code></td>
<td><code>Array</code></td>
<td>An array of metadata names to pull from the service. Includes all fields by default.</td>
</tr>
<tr>
<td><code>from</code></td>
<td><code>Date</code></td>
<td>When paired with <code>to</code> defines the time range of features to display. Required the Feature Layer to be time enabled.</td>
</tr>
<tr>
<td><code>to</code></td>
<td><code>Date</code></td>
<td>When paired with <code>from</code> defines the time range of features to display. Required the Feature Layer to be time enabled.</td>
</tr>
<tr>
<td><code>timeField</code></td>
<td><code>false</code></td>
<td>The name of the field to lookup the time of the feature. Can be an object like <code>{start:'startTime', end:'endTime'}</code> or a string like <code>'created'</code>.</td>
</tr>
<tr>
<td><code>timeFilterMode</code></td>
<td><code>'client'</code> or </code>'server'</code></td>
<td>Determines where features are filtered by time. By default features will be filtered by the server. If set to <code>'client'</code> all features are loaded and filtered on the client before display.</td>
</tr>
<tr>
<td><code>precision</code></td>
<td><code>Integer</code></td>
<td>How many digits of precision to request from the server. <a href="http://en.wikipedia.org/wiki/Decimal_degrees">Wikipedia</a> has a great reference of digit precision to meters.</td>
</tr>
<tr>
<td><code>token</code></td>
<td><code>String</code></td>
<td>If you pass a token in your options it will be included in all requests to the service.</td>
</tr>
<tr>
<td><code>proxy</code></td>
<td><code>String</code></td>
<td>URL of an <a href="https://developers.arcgis.com/javascript/jshelp/ags_proxy.html">ArcGIS API for JavaScript proxies</a> or <a href="https://github.com/Esri/resource-proxy">ArcGIS Resource Proxies</a> to use for proxying POST requests.</td>
</tr>
<tr>
<td><code>useCors</code></td>
<td><code>Boolean</code></td>
<td>If this service should use CORS when making GET requests.</td>
</tr>
</tbody>
</table>
<p><code>L.esri.HeatMapFeatureLayer</code> will also accept any options that can be passed to <a href="https://github.com/Leaflet/Leaflet.heat#lheatlayerlatlngs-options">Leaflet.heat</a> to customize the appearance of the heatmap.</p>
<h3 id="events">Events</h3>
<table>
<thead>
<tr>
<th>Event</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>loading</code></td>
<td><a href=""><LoadingEvent></a></td>
<td>Fires when new features start loading.</td>
</tr>
<tr>
<td><code>load</code></td>
<td><a href=""><Load></a></td>
<td>Fires when all features in the current bounds of the map have loaded.</td>
</tr>
</tbody>
</table>
<p><code>L.esri.Layers.FeatureLayer</code> also fires all <a href="../../api-reference/services/feature-layer.html"><code>L.esri.Services.FeatureLayer</code></a> events.</p>
<h3 id="methods">Methods</h3>
<table>
<thead>
<tr>
<th>Method</th>
<th>Returns</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>getWhere()</code></td>
<td><code>String</code></td>
<td>Returns the current <code>where</code> setting</td>
</tr>
<tr>
<td><code>setWhere(<nobr class="param"><span><String></span> <code>where</code></nobr>, <nobr class="param"><span><Function></span> <code>callback</code></nobr>, <nobr class="param"><span><Object></span> <code>context</code></nobr>)</code></td>
<td><code>this</code></td>
<td>Sets the new <code>where</code> option and refreshes the layer to reflect the new <code>where</code> filter. Accepts an optional callback and function context.</td>
</tr>
<tr>
<td><code>getTimeRange()</code></td>
<td><code>Array</code></td>
<td>Returns the current time range as an array like <code>[from, to]</code></td>
</tr>
<tr>
<td><code>setTimeRange(<nobr class="param"><span><Date></span> <code>from</code></nobr>, <nobr class="param"><span><Date></span> <code>to</code></nobr>, , <nobr class="param"><span><Function></span> <code>callback</code></nobr>, <nobr class="param"><span><Object></span> <code>context</code></nobr>)</code></td>
<td><code>this</code></td>
<td>Sets the current time filter applied to features. An optional callback is run upon completion if <code>timeFilterMode</code> is set to <code>'server'</code>. Also accepts function context as the last argument.</td>
</tr>
<tr>
<td><code>authenticate(<nobr class="param"><span><String></span> <code>token</code></nobr>)</code></td>
<td><code>this</code></td>
<td>Authenticates this service with a new token and runs any pending requests that required a token.</td>
</tr>
<tr>
<td><code>query()</code></td>
<td><code>this</code></td>
<td>
Returns a new <a href=""><code>L.esri.services.Query</code></a> object that can be used to query this layer. Your callback function will be passed a <a href="http://geojson.org/geojson-spec.html#feature-collection-objects">GeoJSON FeatureCollection</a> with the results or an error.
<pre class="js"><code>featureLayer.query()
.within(latlngbounds)
.where("Direction = 'WEST'")
.run(function(error, featureCollection){
console.log(featureCollection);
});</code></pre>
</td>
</tr>
<tr>
<td><code>metadata(<nobr class="param"><span><Function></span> <code>callback</code></nobr>, <nobr class="param"><span><Object></span> <code>context</code></nobr>)</code></td>
<td><code>this</code></td>
<td>
Requests metadata about this Feature Layer. Callback will be called with <code>error</code> and <code>metadata</code>.
<pre class="js"><code>featureLayer.metadata(function(error, metadata){
console.log(metadata);
});</code></pre>
</td>
</tr>
<tr>
<td><code>addFeature(<nobr class="param"><span><<a href="http://geojson.org/geojson-spec.html#feature-objects">GeoJSON Feature</a>></span> <code>feature</code></nobr>, <nobr class="param"><span><Function></span> <code>callback</code></nobr>, <nobr class="param"><span><Object></span> <code>context</code></nobr>)</code></td>
<td><code>this</code></td>
<td>
Adds a new feature to the feature layer. this also adds the feature to the map if creation is successful.
<ul>
<li>Requires authentication as a user who has permission to edit the service in ArcGIS Online or the user who created the service.</li>
<li>Requires the <code>Create</code> capability be enabled on the service. You can check if creation exists by checking the metadata of your service under capabilities in the metadata.</li>
</ul>
</td>
</tr>
<tr>
<td><code>updateFeature(<nobr class="param"><span><<a href="http://geojson.org/geojson-spec.html#feature-objects">GeoJSON Feature</a>></span> <code>feature</code></nobr>, <nobr class="param"><span><Function></span> <code>callback</code></nobr>, <nobr class="param"><span><Object></span> <code>context</code></nobr>)</code></td>
<td><code>this</code></td>
<td>
Update the provided feature on the Feature Layer. This also updates the feature on the map.
<ul>
<li>Requires authentication as a user who has permission to edit the service in ArcGIS Online or the user who created the service.</li>
<li>Requires the <code>Update</code> capability be enabled on the service. You can check if creation exists by checking the metadata of your service under capabilities in the metadata.</li>
</ul>
</td>
</tr>
<tr>
<td><code>deleteFeature(<nobr class="param"><span><String or Integer></span> <code>id</code></nobr>, <nobr class="param"><span><Function></span> <code>callback</code></nobr>, <nobr class="param"><span><Object></span> <code>context</code></nobr>)</code></td>
<td><code>this</code></td>
<td>
Remove the feature with the provided id from the feature layer. This will also remove the feature from the map if it exists.
<ul>
<li>Requires authentication as a user who has permission to edit the service in ArcGIS Online or the user who created the service.</li>
<li>Requires the <code>Update</code> capability be enabled on the service. You can check if creation exists by checking the metadata of your service under capabilities in the metadata.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<h3 id="example">Example</h3>
<pre><code class="language-js"><span class="keyword">var</span> map = <span class="keyword">new</span> L.Map(<span class="string">'map'</span>).setView([<span class="number">40.722868115037</span>,-<span class="number">73.92142295837404</span>], <span class="number">14</span>);
L.esri.basemapLayer(<span class="string">'Gray'</span>).addTo(map);
<span class="keyword">var</span> heatmap = <span class="keyword">new</span> L.esri.HeatmapFeatureLayer(<span class="string">"http://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Graffiti_Locations3/FeatureServer/0"</span>, {
radius: <span class="number">12</span>
}).addTo(map);</code></pre>
<p><a href="http://github.com/esri/esri-leaflet/edit/master/site/source/pages/api-reference/layers/heatmap-feature-layer.md">Edit this page on GitHub</a></p>
</div>
<div style='clear:both;'></div>
</div>
<div class="container centered-text">
<p class="copyright">Esri Leaflet is a project from the <a href="http://pdx.esri.com">Esri PDX R&D Center</a> and the <a href="https://github.com/Esri/esri-leaflet/graphs/contributors">Esri Community</a></p>
</div>
</div>
<script src="../../js/script.js"></script>
</body>
</html>