Rename _ol_source_CartoDB_ to CartoDB
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
import Map from '../src/ol/Map.js';
|
||||||
import View from '../src/ol/View.js';
|
import View from '../src/ol/View.js';
|
||||||
import TileLayer from '../src/ol/layer/Tile.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';
|
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
|
||||||
|
|
||||||
var mapConfig = {
|
var mapConfig = {
|
||||||
@@ -15,7 +15,7 @@ var mapConfig = {
|
|||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
var cartoDBSource = new _ol_source_CartoDB_({
|
var cartoDBSource = new CartoDB({
|
||||||
account: 'documentation',
|
account: 'documentation',
|
||||||
config: mapConfig
|
config: mapConfig
|
||||||
});
|
});
|
||||||
|
|||||||
+10
-10
@@ -15,7 +15,7 @@ import _ol_source_XYZ_ from '../source/XYZ.js';
|
|||||||
* @param {olx.source.CartoDBOptions} options CartoDB options.
|
* @param {olx.source.CartoDBOptions} options CartoDB options.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
var _ol_source_CartoDB_ = function(options) {
|
var CartoDB = function(options) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@@ -54,7 +54,7 @@ var _ol_source_CartoDB_ = function(options) {
|
|||||||
this.initializeMap_();
|
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.
|
* @return {!Object} The current configuration.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_source_CartoDB_.prototype.getConfig = function() {
|
CartoDB.prototype.getConfig = function() {
|
||||||
return this.config_;
|
return this.config_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ _ol_source_CartoDB_.prototype.getConfig = function() {
|
|||||||
* in the config.
|
* in the config.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_source_CartoDB_.prototype.updateConfig = function(config) {
|
CartoDB.prototype.updateConfig = function(config) {
|
||||||
_ol_obj_.assign(this.config_, config);
|
_ol_obj_.assign(this.config_, config);
|
||||||
this.initializeMap_();
|
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.
|
* If using named maps, a key-value lookup with the template parameters.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_source_CartoDB_.prototype.setConfig = function(config) {
|
CartoDB.prototype.setConfig = function(config) {
|
||||||
this.config_ = config || {};
|
this.config_ = config || {};
|
||||||
this.initializeMap_();
|
this.initializeMap_();
|
||||||
};
|
};
|
||||||
@@ -96,7 +96,7 @@ _ol_source_CartoDB_.prototype.setConfig = function(config) {
|
|||||||
* Issue a request to initialize the CartoDB map.
|
* Issue a request to initialize the CartoDB map.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_source_CartoDB_.prototype.initializeMap_ = function() {
|
CartoDB.prototype.initializeMap_ = function() {
|
||||||
var paramHash = JSON.stringify(this.config_);
|
var paramHash = JSON.stringify(this.config_);
|
||||||
if (this.templateCache_[paramHash]) {
|
if (this.templateCache_[paramHash]) {
|
||||||
this.applyTemplate_(this.templateCache_[paramHash]);
|
this.applyTemplate_(this.templateCache_[paramHash]);
|
||||||
@@ -124,7 +124,7 @@ _ol_source_CartoDB_.prototype.initializeMap_ = function() {
|
|||||||
* @param {Event} event Event.
|
* @param {Event} event Event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_source_CartoDB_.prototype.handleInitResponse_ = function(paramHash, event) {
|
CartoDB.prototype.handleInitResponse_ = function(paramHash, event) {
|
||||||
var client = /** @type {XMLHttpRequest} */ (event.target);
|
var client = /** @type {XMLHttpRequest} */ (event.target);
|
||||||
// status will be 0 for file:// urls
|
// status will be 0 for file:// urls
|
||||||
if (!client.status || client.status >= 200 && client.status < 300) {
|
if (!client.status || client.status >= 200 && client.status < 300) {
|
||||||
@@ -148,7 +148,7 @@ _ol_source_CartoDB_.prototype.handleInitResponse_ = function(paramHash, event) {
|
|||||||
* @private
|
* @private
|
||||||
* @param {Event} event Event.
|
* @param {Event} event Event.
|
||||||
*/
|
*/
|
||||||
_ol_source_CartoDB_.prototype.handleInitError_ = function(event) {
|
CartoDB.prototype.handleInitError_ = function(event) {
|
||||||
this.setState(SourceState.ERROR);
|
this.setState(SourceState.ERROR);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -158,9 +158,9 @@ _ol_source_CartoDB_.prototype.handleInitError_ = function(event) {
|
|||||||
* @param {CartoDBLayerInfo} data Result of carto db call.
|
* @param {CartoDBLayerInfo} data Result of carto db call.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_source_CartoDB_.prototype.applyTemplate_ = function(data) {
|
CartoDB.prototype.applyTemplate_ = function(data) {
|
||||||
var tilesUrl = 'https://' + data.cdn_url.https + '/' + this.account_ +
|
var tilesUrl = 'https://' + data.cdn_url.https + '/' + this.account_ +
|
||||||
'/api/v1/map/' + data.layergroupid + '/{z}/{x}/{y}.png';
|
'/api/v1/map/' + data.layergroupid + '/{z}/{x}/{y}.png';
|
||||||
this.setUrl(tilesUrl);
|
this.setUrl(tilesUrl);
|
||||||
};
|
};
|
||||||
export default _ol_source_CartoDB_;
|
export default CartoDB;
|
||||||
|
|||||||
@@ -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';
|
import _ol_source_XYZ_ from '../../../../src/ol/source/XYZ.js';
|
||||||
|
|
||||||
describe('ol.source.CartoDB', function() {
|
describe('ol.source.CartoDB', function() {
|
||||||
|
|
||||||
describe('constructor', function() {
|
describe('constructor', function() {
|
||||||
it('returns a CartoDB source', function() {
|
it('returns a CartoDB source', function() {
|
||||||
var source = new _ol_source_CartoDB_({
|
var source = new CartoDB({
|
||||||
account: 'documentation',
|
account: 'documentation',
|
||||||
config: {}
|
config: {}
|
||||||
});
|
});
|
||||||
expect(source).to.be.a(_ol_source_XYZ_);
|
expect(source).to.be.a(_ol_source_XYZ_);
|
||||||
expect(source).to.be.a(_ol_source_CartoDB_);
|
expect(source).to.be.a(CartoDB);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user