From 8655d5cba26d6b874e66a841794ac1149db2a9fa Mon Sep 17 00:00:00 2001 From: javi Date: Thu, 9 Jan 2014 15:12:57 +0100 Subject: [PATCH] updated leaflet canvas layer --- lib/torque/leaflet/canvas_layer.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/torque/leaflet/canvas_layer.js b/lib/torque/leaflet/canvas_layer.js index 0b6810e..885320d 100644 --- a/lib/torque/leaflet/canvas_layer.js +++ b/lib/torque/leaflet/canvas_layer.js @@ -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; },