diff --git a/lib/torque/gmaps/torque.js b/lib/torque/gmaps/torque.js index 3600f4c..4f611a6 100644 --- a/lib/torque/gmaps/torque.js +++ b/lib/torque/gmaps/torque.js @@ -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); diff --git a/lib/torque/leaflet/torque.js b/lib/torque/leaflet/torque.js index 7c1b2ad..e6828c4 100644 --- a/lib/torque/leaflet/torque.js +++ b/lib/torque/leaflet/torque.js @@ -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)); diff --git a/test/leaflet/torque-layer.js b/test/leaflet/torque-layer.js new file mode 100644 index 0000000..0e7916f --- /dev/null +++ b/test/leaflet/torque-layer.js @@ -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); +}); diff --git a/test/suite.js b/test/suite.js index 259219b..ae075ff 100644 --- a/test/suite.js +++ b/test/suite.js @@ -1,6 +1,7 @@ require('qunitjs'); require('./core'); +require('./leaflet/torque-layer'); require('./torque'); require('./renderer/point'); require('./provider.jsonarray');