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; },