Merge pull request #197 from CartoDB/providerload
renderer and provider are loaded before options.ready is defined, to prevent them from being called before their initialization
This commit is contained in:
commit
be7046e5a0
@ -66,6 +66,9 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
||||
this.options.renderer = this.options.renderer || 'point';
|
||||
this.options.provider = this.options.provider || 'windshaft';
|
||||
|
||||
this.provider = new this.providers[this.options.provider](options);
|
||||
this.renderer = new this.renderers[this.options.renderer](this.getCanvas(), options);
|
||||
|
||||
options.ready = function() {
|
||||
self.fire("change:bounds", {
|
||||
bounds: self.provider.getBounds()
|
||||
@ -78,9 +81,6 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
||||
self.setKey(self.key);
|
||||
};
|
||||
|
||||
this.provider = new this.providers[this.options.provider](options);
|
||||
this.renderer = new this.renderers[this.options.renderer](this.getCanvas(), options);
|
||||
|
||||
this.renderer.on("allIconsLoaded", this.render.bind(this));
|
||||
|
||||
|
||||
@ -279,7 +279,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
||||
},
|
||||
|
||||
/**
|
||||
* helper function, does the same than ``setKey`` but only
|
||||
* helper function, does the same than ``setKey`` but only
|
||||
* accepts scalars.
|
||||
*/
|
||||
setStep: function(time) {
|
||||
@ -290,17 +290,17 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
||||
},
|
||||
|
||||
/**
|
||||
* transform from animation step to Date object
|
||||
* transform from animation step to Date object
|
||||
* that contains the animation time
|
||||
*
|
||||
* ``step`` should be between 0 and ``steps - 1``
|
||||
* ``step`` should be between 0 and ``steps - 1``
|
||||
*/
|
||||
stepToTime: function(step) {
|
||||
var times = this.provider.getKeySpan();
|
||||
var time = times.start + (times.end - times.start)*(step/this.provider.getSteps());
|
||||
return new Date(time);
|
||||
},
|
||||
|
||||
|
||||
timeToStep: function(timestamp) {
|
||||
if (typeof timestamp === "Date") timestamp = timestamp.getTime();
|
||||
if (!this.provider) return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user