Merge pull request #5164 from fredj/cartodb_cleanup

Cartodb cleanup
This commit is contained in:
Frédéric Junod
2016-04-04 14:55:27 +02:00
+7 -7
View File
@@ -1,5 +1,6 @@
goog.provide('ol.source.CartoDB'); goog.provide('ol.source.CartoDB');
goog.require('ol.object');
goog.require('ol.source.State'); goog.require('ol.source.State');
goog.require('ol.source.XYZ'); goog.require('ol.source.XYZ');
@@ -28,7 +29,7 @@ ol.source.CartoDB = function(options) {
this.mapId_ = options.map || ''; this.mapId_ = options.map || '';
/** /**
* @type {Object} * @type {!Object}
* @private * @private
*/ */
this.config_ = options.config || {}; this.config_ = options.config || {};
@@ -47,6 +48,7 @@ ol.source.CartoDB = function(options) {
maxZoom: options.maxZoom !== undefined ? options.maxZoom : 18, maxZoom: options.maxZoom !== undefined ? options.maxZoom : 18,
minZoom: options.minZoom, minZoom: options.minZoom,
projection: options.projection, projection: options.projection,
state: ol.source.State.LOADING,
wrapX: options.wrapX wrapX: options.wrapX
}); });
this.initializeMap_(); this.initializeMap_();
@@ -56,7 +58,7 @@ goog.inherits(ol.source.CartoDB, ol.source.XYZ);
/** /**
* Returns the current config. * Returns the current config.
* @return {Object} The current configuration. * @return {!Object} The current configuration.
* @api * @api
*/ */
ol.source.CartoDB.prototype.getConfig = function() { ol.source.CartoDB.prototype.getConfig = function() {
@@ -71,9 +73,7 @@ ol.source.CartoDB.prototype.getConfig = function() {
* @api * @api
*/ */
ol.source.CartoDB.prototype.updateConfig = function(config) { ol.source.CartoDB.prototype.updateConfig = function(config) {
for (var key in config) { ol.object.assign(this.config_, config);
this.config_[key] = config[key];
}
this.initializeMap_(); this.initializeMap_();
}; };
@@ -100,8 +100,7 @@ ol.source.CartoDB.prototype.initializeMap_ = function() {
this.applyTemplate_(this.templateCache_[paramHash]); this.applyTemplate_(this.templateCache_[paramHash]);
return; return;
} }
var mapUrl = 'https://' + this.account_ + var mapUrl = 'https://' + this.account_ + '.cartodb.com/api/v1/map';
'.cartodb.com/api/v1/map';
if (this.mapId_) { if (this.mapId_) {
mapUrl += '/named/' + this.mapId_; mapUrl += '/named/' + this.mapId_;
@@ -135,6 +134,7 @@ ol.source.CartoDB.prototype.handleInitResponse_ = function(paramHash, event) {
} }
this.applyTemplate_(response); this.applyTemplate_(response);
this.templateCache_[paramHash] = response; this.templateCache_[paramHash] = response;
this.setState(ol.source.State.READY);
} else { } else {
this.setState(ol.source.State.ERROR); this.setState(ol.source.State.ERROR);
} }