updated leaflet canvas layer

This commit is contained in:
javi 2014-01-09 15:12:57 +01:00
parent 7bcb2ef2f2
commit 8655d5cba2

View File

@ -21,12 +21,18 @@ L.CanvasLayer = L.Class.extend({
tileLoader: false // installs tile loading events
},
initialize: function (options) {
initialize: function (options) {
var self = this;
options = options || {};
//this.project = this._project.bind(this);
this.render = this.render.bind(this);
L.Util.setOptions(this, options);
this._canvas = document.createElement('canvas');
this._canvas.style.position = 'absolute';
this._canvas.style.top = 0;
this._canvas.style.left = 0;
this._canvas.style.zIndex = options.zIndex || 0;
this._ctx = this._canvas.getContext('2d');
var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
@ -38,7 +44,11 @@ L.CanvasLayer = L.Class.extend({
onAdd: function (map) {
this._map = map;
this._staticPane = map._createPane('leaflet-tile-pane', map._container);
//this._staticPane = map._createPane('leaflet-tile-pane', map._container);
if (!map._panes.staticPane) {
map._panes.staticPane = map._createPane('leaflet-tile-pane', map._container);
}
this._staticPane = map._panes.staticPane
this._staticPane.appendChild(this._canvas);
map.on({
@ -88,6 +98,10 @@ L.CanvasLayer = L.Class.extend({
return this;
},
setZIndex: function(zIndex) {
this._canvas.style.zIndex = zIndex;
},
bringToFront: function () {
return this;
},