admits tilejson option

This commit is contained in:
Francisco Dans 2015-09-21 15:01:49 +02:00
parent 334e2593d5
commit 4527d4a300

View File

@ -457,29 +457,46 @@
"&callback=?" + (extra ? "&" + extra: '');
var map_instance_time = Profiler.metric('torque.provider.windshaft.layergroup.time').start();
if (this.options.tileJSON) url = this.options.tileJSON;
torque.net.jsonp(url, function (data) {
data = {
"translate": [0, 100],
"resolution": 2,
"data_steps": 365,
"column_type": "number",
"tiles": ["http://{s}.ashbu.cartocdn.com/viz2/api/v1/map/cf28c540d3cf15a29a759f84ff440679:0/0/{z}/{x}/{y}.json.torque"]
};
map_instance_time.end();
if (data) {
if (data.errors){
self.options.errorCallback && self.options.errorCallback(data.errors);
return;
}
var torque_key = Object.keys(data.metadata.torque)[0]
var opt = data.metadata.torque[torque_key];
for(var k in opt) {
self.options[k] = opt[k];
if (self.options.tileJSON){
for(var k in data) {
self.options[k] = data[k];
}
self.templateUrl = data.tiles[0];
self._setReady(true);
}
// use cdn_url if present
if (data.cdn_url) {
var c = self.options.cdn_url = self.options.cdn_url || {};
c.http = data.cdn_url.http || c.http;
c.https = data.cdn_url.https || c.https;
else{
var torque_key = Object.keys(data.metadata.torque)[0]
var opt = data.metadata.torque[torque_key];
for(var k in opt) {
self.options[k] = opt[k];
}
// use cdn_url if present
if (data.cdn_url) {
var c = self.options.cdn_url = self.options.cdn_url || {};
c.http = data.cdn_url.http || c.http;
c.https = data.cdn_url.https || c.https;
}
self.templateUrl = self.url() + "/api/v1/map/" + data.layergroupid + "/" + torque_key + "/{z}/{x}/{y}.json.torque";
self._setReady(true);
}
self.templateUrl = self.url() + "/api/v1/map/" + data.layergroupid + "/" + torque_key + "/{z}/{x}/{y}.json.torque";
self._setReady(true);
} else {
Profiler.metric('torque.provider.windshaft.layergroup.error').inc();
}
Profiler.metric('torque.provider.windshaft.layergroup.error').inc();
}
}, { callbackName: self.options.instanciateCallback });
}