Merge pull request #8798 from fredj/rawgit

Use unpkg.com instead of rawgit.com
This commit is contained in:
Frédéric Junod
2018-10-12 11:04:39 +02:00
committed by GitHub
6 changed files with 42 additions and 41 deletions

View File

@@ -92,30 +92,30 @@ class TileRange {
}
/**
* @return {number} Height.
*/
* @return {number} Height.
*/
getHeight() {
return this.maxY - this.minY + 1;
}
/**
* @return {import("./size.js").Size} Size.
*/
* @return {import("./size.js").Size} Size.
*/
getSize() {
return [this.getWidth(), this.getHeight()];
}
/**
* @return {number} Width.
*/
* @return {number} Width.
*/
getWidth() {
return this.maxX - this.minX + 1;
}
/**
* @param {TileRange} tileRange Tile range.
* @return {boolean} Intersects.
*/
* @param {TileRange} tileRange Tile range.
* @return {boolean} Intersects.
*/
intersects(tileRange) {
return this.minX <= tileRange.maxX &&
this.maxX >= tileRange.minX &&

View File

@@ -32,8 +32,8 @@ import SourceState from './State.js';
* @typedef {Object} Options
* @property {AttributionLike} [attributions]
* @property {import("../proj.js").ProjectionLike} projection
* @property {SourceState} [state]
* @property {boolean} [wrapX]
* @property {SourceState} [state='ready']
* @property {boolean} [wrapX=false]
*/
@@ -64,7 +64,7 @@ class Source extends BaseObject {
* @private
* @type {?Attribution}
*/
this.attributions_ = this.adaptAttributions_(options.attributions);
this.attributions_ = adaptAttributions(options.attributions);
/**
* This source is currently loading data. Sources that defer loading to the
@@ -88,30 +88,6 @@ class Source extends BaseObject {
}
/**
* Turns the attributions option into an attributions function.
* @param {AttributionLike|undefined} attributionLike The attribution option.
* @return {?Attribution} An attribution function (or null).
*/
adaptAttributions_(attributionLike) {
if (!attributionLike) {
return null;
}
if (Array.isArray(attributionLike)) {
return function(frameState) {
return attributionLike;
};
}
if (typeof attributionLike === 'function') {
return attributionLike;
}
return function(frameState) {
return [attributionLike];
};
}
/**
* Get the attribution function for the source.
* @return {?Attribution} Attribution function.
@@ -167,7 +143,7 @@ class Source extends BaseObject {
* @api
*/
setAttributions(attributions) {
this.attributions_ = this.adaptAttributions_(attributions);
this.attributions_ = adaptAttributions(attributions);
this.changed();
}
@@ -195,4 +171,29 @@ class Source extends BaseObject {
Source.prototype.forEachFeatureAtCoordinate = VOID;
/**
* Turns the attributions option into an attributions function.
* @param {AttributionLike|undefined} attributionLike The attribution option.
* @return {?Attribution} An attribution function (or null).
*/
function adaptAttributions(attributionLike) {
if (!attributionLike) {
return null;
}
if (Array.isArray(attributionLike)) {
return function(frameState) {
return attributionLike;
};
}
if (typeof attributionLike === 'function') {
return attributionLike;
}
return function(frameState) {
return [attributionLike];
};
}
export default Source;