Skip to content

Commit

Permalink
migrate to modern leaflet version
Browse files Browse the repository at this point in the history
tested with LeafLet 1.6
  • Loading branch information
se-ti committed Nov 12, 2020
1 parent 71f6164 commit 9203154
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/heatcanvas-leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@

import {default as HeatCanvas} from './heatcanvas.js';

L.TileLayer.HeatCanvas = L.Class.extend({
L.TileLayer.HeatCanvas = L.Layer.extend({

initialize: function(options, heatCanvasOptions){
L.Util.setOptions(this, options);

this.heatCanvasOptions = heatCanvasOptions;
this.data = [];
this._onRenderingStart = null;
Expand Down Expand Up @@ -56,12 +58,16 @@ L.TileLayer.HeatCanvas = L.Class.extend({
this._step = options.step || 1;
this._degree = options.degree || HeatCanvas.LINEAR;
this._opacity = options.opacity || 0.6;
this._zIndex = options.zIndex || null;
this._colorscheme = options.colorscheme || null;

var container = L.DomUtil.create('div', 'leaflet-heatmap-container');
container.style.position = 'absolute';
container.style.width = this.map.getSize().x+"px";
container.style.height = this.map.getSize().y+"px";
if (this._zIndex) {
container.style.zIndex = this._zIndex;
}

var canv = document.createElement("canvas");
canv.width = this.map.getSize().x;
Expand Down Expand Up @@ -109,7 +115,8 @@ L.TileLayer.HeatCanvas = L.Class.extend({
},

clear: function(){
this.heatmap.clear();
if (this.heatmap)
this.heatmap.clear();
this.data = [];
},

Expand All @@ -119,8 +126,8 @@ L.TileLayer.HeatCanvas = L.Class.extend({

});

L.TileLayer.heatcanvas = function (options) {
return new L.TileLayer.HeatCanvas(options);
L.TileLayer.heatcanvas = function (options, heatCanvasOptions) {
return new L.TileLayer.HeatCanvas(options, heatCanvasOptions);
};

export default L.TitleLayer.heatcanvas;
export default L.TileLayer.heatcanvas;

0 comments on commit 9203154

Please sign in to comment.