Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
support leaflet-heat
  • Loading branch information
tmcw committed Aug 14, 2014
1 parent f3daf96 commit 4d8c46a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions index.html
Expand Up @@ -32,6 +32,7 @@
<button id='snap' class='ui-button'>Take a snapshot</button>
<div id='snapshot'></div>
<div id='map'></div>
<script src='https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-heat/v0.1.0/leaflet-heat.js'></script>
<script src='leaflet-image.js'></script>
<script>
L.mapbox.accessToken = 'pk.eyJ1IjoidG1jdyIsImEiOiJIZmRUQjRBIn0.lRARalfaGHnPdRcc-7QZYQ';
Expand All @@ -52,6 +53,20 @@
snapshot.innerHTML = '';
snapshot.appendChild(img);
}

var heat = L.heatLayer([], {maxZoom: 18}).addTo(map);
var draw = true;

// add points on mouse move (except when interacting with the map)
map.on({
movestart: function () { draw = false; },
moveend: function () { draw = true; },
mousemove: function (e) {
if (draw) {
heat.addLatLng(e.latlng);
}
}
})
</script>
</body>
</html>
1 change: 1 addition & 0 deletions index.js
Expand Up @@ -20,6 +20,7 @@ module.exports = function leafletImage(map, callback) {

function drawTileLayer(l) {
if (l instanceof L.TileLayer) layerQueue.defer(handleTileLayer, l);
else if (l._heat) layerQueue.defer(handlePathRoot, l._canvas);
}

function drawMarkerLayer(l) {
Expand Down
1 change: 1 addition & 0 deletions leaflet-image.js
Expand Up @@ -21,6 +21,7 @@ module.exports = function leafletImage(map, callback) {

function drawTileLayer(l) {
if (l instanceof L.TileLayer) layerQueue.defer(handleTileLayer, l);
else if (l._heat) layerQueue.defer(handlePathRoot, l._canvas);
}

function drawMarkerLayer(l) {
Expand Down

0 comments on commit 4d8c46a

Please sign in to comment.