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

View File

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