From fe0d05900f0f3ef3b4382e185da04b94dec1c05c Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 8 Jan 2018 13:55:12 -0700 Subject: [PATCH] Rename _ol_source_CartoDB_ to CartoDB --- examples/cartodb.js | 4 ++-- src/ol/source/CartoDB.js | 20 ++++++++++---------- test/spec/ol/source/cartodb.test.js | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/cartodb.js b/examples/cartodb.js index b198f01ab7..8bbf3a1d7f 100644 --- a/examples/cartodb.js +++ b/examples/cartodb.js @@ -1,7 +1,7 @@ import Map from '../src/ol/Map.js'; import View from '../src/ol/View.js'; import TileLayer from '../src/ol/layer/Tile.js'; -import _ol_source_CartoDB_ from '../src/ol/source/CartoDB.js'; +import CartoDB from '../src/ol/source/CartoDB.js'; import _ol_source_OSM_ from '../src/ol/source/OSM.js'; var mapConfig = { @@ -15,7 +15,7 @@ var mapConfig = { }] }; -var cartoDBSource = new _ol_source_CartoDB_({ +var cartoDBSource = new CartoDB({ account: 'documentation', config: mapConfig }); diff --git a/src/ol/source/CartoDB.js b/src/ol/source/CartoDB.js index 57c24d60ce..f8872a0e1c 100644 --- a/src/ol/source/CartoDB.js +++ b/src/ol/source/CartoDB.js @@ -15,7 +15,7 @@ import _ol_source_XYZ_ from '../source/XYZ.js'; * @param {olx.source.CartoDBOptions} options CartoDB options. * @api */ -var _ol_source_CartoDB_ = function(options) { +var CartoDB = function(options) { /** * @type {string} @@ -54,7 +54,7 @@ var _ol_source_CartoDB_ = function(options) { this.initializeMap_(); }; -inherits(_ol_source_CartoDB_, _ol_source_XYZ_); +inherits(CartoDB, _ol_source_XYZ_); /** @@ -62,7 +62,7 @@ inherits(_ol_source_CartoDB_, _ol_source_XYZ_); * @return {!Object} The current configuration. * @api */ -_ol_source_CartoDB_.prototype.getConfig = function() { +CartoDB.prototype.getConfig = function() { return this.config_; }; @@ -73,7 +73,7 @@ _ol_source_CartoDB_.prototype.getConfig = function() { * in the config. * @api */ -_ol_source_CartoDB_.prototype.updateConfig = function(config) { +CartoDB.prototype.updateConfig = function(config) { _ol_obj_.assign(this.config_, config); this.initializeMap_(); }; @@ -86,7 +86,7 @@ _ol_source_CartoDB_.prototype.updateConfig = function(config) { * If using named maps, a key-value lookup with the template parameters. * @api */ -_ol_source_CartoDB_.prototype.setConfig = function(config) { +CartoDB.prototype.setConfig = function(config) { this.config_ = config || {}; this.initializeMap_(); }; @@ -96,7 +96,7 @@ _ol_source_CartoDB_.prototype.setConfig = function(config) { * Issue a request to initialize the CartoDB map. * @private */ -_ol_source_CartoDB_.prototype.initializeMap_ = function() { +CartoDB.prototype.initializeMap_ = function() { var paramHash = JSON.stringify(this.config_); if (this.templateCache_[paramHash]) { this.applyTemplate_(this.templateCache_[paramHash]); @@ -124,7 +124,7 @@ _ol_source_CartoDB_.prototype.initializeMap_ = function() { * @param {Event} event Event. * @private */ -_ol_source_CartoDB_.prototype.handleInitResponse_ = function(paramHash, event) { +CartoDB.prototype.handleInitResponse_ = function(paramHash, event) { var client = /** @type {XMLHttpRequest} */ (event.target); // status will be 0 for file:// urls if (!client.status || client.status >= 200 && client.status < 300) { @@ -148,7 +148,7 @@ _ol_source_CartoDB_.prototype.handleInitResponse_ = function(paramHash, event) { * @private * @param {Event} event Event. */ -_ol_source_CartoDB_.prototype.handleInitError_ = function(event) { +CartoDB.prototype.handleInitError_ = function(event) { this.setState(SourceState.ERROR); }; @@ -158,9 +158,9 @@ _ol_source_CartoDB_.prototype.handleInitError_ = function(event) { * @param {CartoDBLayerInfo} data Result of carto db call. * @private */ -_ol_source_CartoDB_.prototype.applyTemplate_ = function(data) { +CartoDB.prototype.applyTemplate_ = function(data) { var tilesUrl = 'https://' + data.cdn_url.https + '/' + this.account_ + '/api/v1/map/' + data.layergroupid + '/{z}/{x}/{y}.png'; this.setUrl(tilesUrl); }; -export default _ol_source_CartoDB_; +export default CartoDB; diff --git a/test/spec/ol/source/cartodb.test.js b/test/spec/ol/source/cartodb.test.js index 635a5dbdbf..ea25dc2986 100644 --- a/test/spec/ol/source/cartodb.test.js +++ b/test/spec/ol/source/cartodb.test.js @@ -1,16 +1,16 @@ -import _ol_source_CartoDB_ from '../../../../src/ol/source/CartoDB.js'; +import CartoDB from '../../../../src/ol/source/CartoDB.js'; import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js'; describe('ol.source.CartoDB', function() { describe('constructor', function() { it('returns a CartoDB source', function() { - var source = new _ol_source_CartoDB_({ + var source = new CartoDB({ account: 'documentation', config: {} }); expect(source).to.be.a(_ol_source_XYZ_); - expect(source).to.be.a(_ol_source_CartoDB_); + expect(source).to.be.a(CartoDB); }); }); });