Remove ol/Attribution
This commit is contained in:
@@ -1,99 +0,0 @@
|
||||
/**
|
||||
* @module ol/Attribution
|
||||
*/
|
||||
import _ol_TileRange_ from './TileRange.js';
|
||||
import _ol_math_ from './math.js';
|
||||
import _ol_tilegrid_ from './tilegrid.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* An attribution for a layer source.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* source: new ol.source.OSM({
|
||||
* attributions: [
|
||||
* new ol.Attribution({
|
||||
* html: 'All maps © ' +
|
||||
* '<a href="https://www.opencyclemap.org/">OpenCycleMap</a>'
|
||||
* }),
|
||||
* ol.source.OSM.ATTRIBUTION
|
||||
* ],
|
||||
* ..
|
||||
*
|
||||
* @constructor
|
||||
* @deprecated This class is deprecated and will removed in the next major release.
|
||||
* @param {olx.AttributionOptions} options Attribution options.
|
||||
* @struct
|
||||
* @api
|
||||
*/
|
||||
var _ol_Attribution_ = function(options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.html_ = options.html;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Object.<string, Array.<ol.TileRange>>}
|
||||
*/
|
||||
this.tileRanges_ = options.tileRanges ? options.tileRanges : null;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the attribution markup.
|
||||
* @return {string} The attribution HTML.
|
||||
* @api
|
||||
*/
|
||||
_ol_Attribution_.prototype.getHTML = function() {
|
||||
return this.html_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Object.<string, ol.TileRange>} tileRanges Tile ranges.
|
||||
* @param {!ol.tilegrid.TileGrid} tileGrid Tile grid.
|
||||
* @param {!ol.proj.Projection} projection Projection.
|
||||
* @return {boolean} Intersects any tile range.
|
||||
*/
|
||||
_ol_Attribution_.prototype.intersectsAnyTileRange = function(tileRanges, tileGrid, projection) {
|
||||
if (!this.tileRanges_) {
|
||||
return true;
|
||||
}
|
||||
var i, ii, tileRange, zKey;
|
||||
for (zKey in tileRanges) {
|
||||
if (!(zKey in this.tileRanges_)) {
|
||||
continue;
|
||||
}
|
||||
tileRange = tileRanges[zKey];
|
||||
var testTileRange;
|
||||
for (i = 0, ii = this.tileRanges_[zKey].length; i < ii; ++i) {
|
||||
testTileRange = this.tileRanges_[zKey][i];
|
||||
if (testTileRange.intersects(tileRange)) {
|
||||
return true;
|
||||
}
|
||||
var extentTileRange = tileGrid.getTileRangeForExtentAndZ(
|
||||
_ol_tilegrid_.extentFromProjection(projection), parseInt(zKey, 10));
|
||||
var width = extentTileRange.getWidth();
|
||||
if (tileRange.minX < extentTileRange.minX ||
|
||||
tileRange.maxX > extentTileRange.maxX) {
|
||||
if (testTileRange.intersects(new _ol_TileRange_(
|
||||
_ol_math_.modulo(tileRange.minX, width),
|
||||
_ol_math_.modulo(tileRange.maxX, width),
|
||||
tileRange.minY, tileRange.maxY))) {
|
||||
return true;
|
||||
}
|
||||
if (tileRange.getWidth() > width &&
|
||||
testTileRange.intersects(extentTileRange)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
export default _ol_Attribution_;
|
||||
@@ -174,7 +174,7 @@ _ol_control_Attribution_.prototype.getSourceAttributions_ = function(frameState)
|
||||
continue;
|
||||
}
|
||||
|
||||
var attributionGetter = source.getAttributions2();
|
||||
var attributionGetter = source.getAttributions();
|
||||
if (!attributionGetter) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @module ol/source/Source
|
||||
*/
|
||||
import {inherits, nullFunction} from '../index.js';
|
||||
import _ol_Attribution_ from '../Attribution.js';
|
||||
import _ol_Object_ from '../Object.js';
|
||||
import _ol_proj_ from '../proj.js';
|
||||
import _ol_source_State_ from '../source/State.js';
|
||||
@@ -33,15 +32,9 @@ var _ol_source_Source_ = function(options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<ol.Attribution>}
|
||||
* @type {?ol.Attribution}
|
||||
*/
|
||||
this.attributions_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {?ol.Attribution2}
|
||||
*/
|
||||
this.attributions2_ = this.adaptAttributions_(options.attributions);
|
||||
this.attributions_ = this.adaptAttributions_(options.attributions);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -68,42 +61,14 @@ inherits(_ol_source_Source_, _ol_Object_);
|
||||
|
||||
/**
|
||||
* Turns the attributions option into an attributions function.
|
||||
* @suppress {deprecated}
|
||||
* @param {ol.AttributionLike|undefined} attributionLike The attribution option.
|
||||
* @return {?ol.Attribution2} An attribution function (or null).
|
||||
* @return {?ol.Attribution} An attribution function (or null).
|
||||
*/
|
||||
_ol_source_Source_.prototype.adaptAttributions_ = function(attributionLike) {
|
||||
if (!attributionLike) {
|
||||
return null;
|
||||
}
|
||||
if (attributionLike instanceof _ol_Attribution_) {
|
||||
|
||||
// TODO: remove attributions_ in next major release
|
||||
this.attributions_ = [attributionLike];
|
||||
|
||||
return function(frameState) {
|
||||
return [attributionLike.getHTML()];
|
||||
};
|
||||
}
|
||||
if (Array.isArray(attributionLike)) {
|
||||
if (attributionLike[0] instanceof _ol_Attribution_) {
|
||||
|
||||
// TODO: remove attributions_ in next major release
|
||||
this.attributions_ = attributionLike;
|
||||
|
||||
var attributions = attributionLike.map(function(attribution) {
|
||||
return attribution.getHTML();
|
||||
});
|
||||
return function(frameState) {
|
||||
return attributions;
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: remove attributions_ in next major release
|
||||
this.attributions_ = attributionLike.map(function(attribution) {
|
||||
return new _ol_Attribution_({html: attribution});
|
||||
});
|
||||
|
||||
return function(frameState) {
|
||||
return attributionLike;
|
||||
};
|
||||
@@ -113,11 +78,6 @@ _ol_source_Source_.prototype.adaptAttributions_ = function(attributionLike) {
|
||||
return attributionLike;
|
||||
}
|
||||
|
||||
// TODO: remove attributions_ in next major release
|
||||
this.attributions_ = [
|
||||
new _ol_Attribution_({html: attributionLike})
|
||||
];
|
||||
|
||||
return function(frameState) {
|
||||
return [attributionLike];
|
||||
};
|
||||
@@ -138,24 +98,14 @@ _ol_source_Source_.prototype.forEachFeatureAtCoordinate = nullFunction;
|
||||
|
||||
|
||||
/**
|
||||
* Get the attributions of the source.
|
||||
* @return {Array.<ol.Attribution>} Attributions.
|
||||
* @api
|
||||
* Get the attribution function for the source.
|
||||
* @return {?ol.Attribution} Attribution function.
|
||||
*/
|
||||
_ol_source_Source_.prototype.getAttributions = function() {
|
||||
return this.attributions_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the attribution function for the source.
|
||||
* @return {?ol.Attribution2} Attribution function.
|
||||
*/
|
||||
_ol_source_Source_.prototype.getAttributions2 = function() {
|
||||
return this.attributions2_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the logo of the source.
|
||||
* @return {string|olx.LogoOptions|undefined} Logo.
|
||||
@@ -213,12 +163,12 @@ _ol_source_Source_.prototype.refresh = function() {
|
||||
/**
|
||||
* Set the attributions of the source.
|
||||
* @param {ol.AttributionLike|undefined} attributions Attributions.
|
||||
* Can be passed as `string`, `Array<string>`, `{@link ol.Attribution2}`,
|
||||
* Can be passed as `string`, `Array<string>`, `{@link ol.Attribution}`,
|
||||
* or `undefined`.
|
||||
* @api
|
||||
*/
|
||||
_ol_source_Source_.prototype.setAttributions = function(attributions) {
|
||||
this.attributions2_ = this.adaptAttributions_(attributions);
|
||||
this.attributions_ = this.adaptAttributions_(attributions);
|
||||
this.changed();
|
||||
};
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ _ol_source_TileJSON_.prototype.handleTileJSONResponse = function(tileJSON) {
|
||||
this.tileUrlFunction =
|
||||
_ol_TileUrlFunction_.createFromTemplates(tileJSON.tiles, tileGrid);
|
||||
|
||||
if (tileJSON.attribution !== undefined && !this.getAttributions2()) {
|
||||
if (tileJSON.attribution !== undefined && !this.getAttributions()) {
|
||||
var attributionExtent = extent !== undefined ?
|
||||
extent : epsg4326Projection.getExtent();
|
||||
|
||||
|
||||
@@ -75,10 +75,9 @@ ol.AtlasManagerInfo;
|
||||
* It represents either
|
||||
* * a simple string (e.g. `'© Acme Inc.'`)
|
||||
* * an array of simple strings (e.g. `['© Acme Inc.', '© Bacme Inc.']`)
|
||||
* * a function that returns a string or array of strings (`{@link ol.Attribution2}`)
|
||||
* * a function that returns a string or array of strings (`{@link ol.Attribution}`)
|
||||
*
|
||||
* Note that the `{@link ol.Attribution}` constructor is deprecated.
|
||||
* @typedef {string|Array.<string>|ol.Attribution2|ol.Attribution|Array.<ol.Attribution>}
|
||||
* @typedef {string|Array.<string>|ol.Attribution}
|
||||
*/
|
||||
ol.AttributionLike;
|
||||
|
||||
@@ -89,7 +88,7 @@ ol.AttributionLike;
|
||||
*
|
||||
* @typedef {function(olx.FrameState): (string|Array.<string>)}
|
||||
*/
|
||||
ol.Attribution2;
|
||||
ol.Attribution;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user