Involves additions to (there will be subsequent pull requests for other classes): - ol.Attribution - ol.Collection - ol.Expression - ol.Feature - ol.Geolocation - ol.Map - ol.Object - ol.Overlay - ol.Projection - ol.View2D - ol.control.Attribution - ol.control.Control - ol.control.FullScreen - ol.control.Logo - ol.control.MousePosition - ol.control.ScaleLine - ol.control.Zoom - ol.control.ZoomSlider - ol.dom.Input - ol.filter.Filter - ol.filter.Geometry - ol.filter.Logical
73 lines
1.5 KiB
JavaScript
73 lines
1.5 KiB
JavaScript
goog.provide('ol.Attribution');
|
|
|
|
goog.require('ol.TileRange');
|
|
|
|
|
|
|
|
/**
|
|
* Create a new attribution to be associated with a layer source.
|
|
*
|
|
* Example:
|
|
*
|
|
* source: new ol.source.OSM({
|
|
* attributions: [
|
|
* new ol.Attribution(
|
|
* 'All maps © ' +
|
|
* '<a href="http://www.opencyclemap.org/">OpenCycleMap</a>'),
|
|
* ol.source.OSM.DATA_ATTRIBUTION
|
|
* ],
|
|
* ..
|
|
*
|
|
* @constructor
|
|
* @param {string} html The markup to use for display of the attribution.
|
|
* @param {Object.<string, Array.<ol.TileRange>>=} opt_tileRanges Tile ranges
|
|
* (FOR INTERNAL USE ONLY).
|
|
*/
|
|
ol.Attribution = function(html, opt_tileRanges) {
|
|
|
|
/**
|
|
* @private
|
|
* @type {string}
|
|
*/
|
|
this.html_ = html;
|
|
|
|
/**
|
|
* @private
|
|
* @type {Object.<string, Array.<ol.TileRange>>}
|
|
*/
|
|
this.tileRanges_ = opt_tileRanges || null;
|
|
|
|
};
|
|
|
|
|
|
/**
|
|
* @return {string} HTML.
|
|
*/
|
|
ol.Attribution.prototype.getHTML = function() {
|
|
return this.html_;
|
|
};
|
|
|
|
|
|
/**
|
|
* @param {Object.<string, ol.TileRange>} tileRanges Tile ranges.
|
|
* @return {boolean} Intersects any tile range.
|
|
*/
|
|
ol.Attribution.prototype.intersectsAnyTileRange = function(tileRanges) {
|
|
if (goog.isNull(this.tileRanges_)) {
|
|
return true;
|
|
}
|
|
var i, ii, tileRange, z;
|
|
for (z in tileRanges) {
|
|
if (!(z in this.tileRanges_)) {
|
|
continue;
|
|
}
|
|
tileRange = tileRanges[z];
|
|
for (i = 0, ii = this.tileRanges_[z].length; i < ii; ++i) {
|
|
if (this.tileRanges_[z][i].intersects(tileRange)) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
};
|