From 02d262e387a80c921d2a8634e0eac02a28a60dd5 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 4 Apr 2016 12:41:42 +0200 Subject: [PATCH 1/2] Fix ol.source.CartoDB 'loading' state --- src/ol/source/cartodb.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ol/source/cartodb.js b/src/ol/source/cartodb.js index 9ff67ac463..37a5c1de8c 100644 --- a/src/ol/source/cartodb.js +++ b/src/ol/source/cartodb.js @@ -47,6 +47,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_(); @@ -100,8 +101,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 +135,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); } From a42d76d69dc9cf6247562436211a8f83b9c21973 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 4 Apr 2016 12:42:08 +0200 Subject: [PATCH 2/2] Use ol.object.assign to update config properties in ol.source.CartoDB --- src/ol/source/cartodb.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ol/source/cartodb.js b/src/ol/source/cartodb.js index 37a5c1de8c..21a8d8df02 100644 --- a/src/ol/source/cartodb.js +++ b/src/ol/source/cartodb.js @@ -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 || {}; @@ -57,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() { @@ -72,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_(); };