Adds key property to torque layers to keep property publicaly exposed

This commit is contained in:
Raul Ochoa 2015-12-15 14:53:46 +01:00
parent 2d5542a28c
commit d478fdc1b0
4 changed files with 20 additions and 0 deletions

View File

@ -10,6 +10,11 @@ function GMapsTorqueLayer(options) {
throw new Error("browser is not supported by torque");
}
this.keys = [0];
Object.defineProperty(this, 'key', {
get: function() {
return this.getKey();
}
});
this.shader = null;
this.ready = false;
this.options = torque.extend({}, options);

View File

@ -27,6 +27,11 @@ L.TorqueLayer = L.CanvasLayer.extend({
}
options.tileLoader = true;
this.keys = [0];
Object.defineProperty(this, 'key', {
get: function() {
return this.getKey();
}
});
this.prevRenderedKey = 0;
if (options.cartocss) {
torque.extend(options, torque.common.TorqueLayer.optionsFromCartoCSS(options.cartocss));

View File

@ -0,0 +1,9 @@
var torque = require('../../lib/torque/index');
QUnit.module('leaflet-torque-layer');
test('exposes key property', function(assert) {
var torqueLayer = new L.TorqueLayer({});
assert.equal(torqueLayer.key, 0);
assert.equal(torqueLayer.getKey(), torqueLayer.key);
});

View File

@ -1,6 +1,7 @@
require('qunitjs');
require('./core');
require('./leaflet/torque-layer');
require('./torque');
require('./renderer/point');
require('./provider.jsonarray');