Merge pull request #947 from elemoine/attribution

Make ol.Attribution take an options object
This commit is contained in:
Éric Lemoine
2013-09-02 03:10:41 -07:00
13 changed files with 96 additions and 64 deletions

View File

@@ -1,3 +1,10 @@
/**
* @typedef {Object} ol.AttributionOptions
* @property {string} html HTML markup for this attribution.
* @property {Object.<string, Array.<ol.TileRange>>|undefined} tileRanges
* Tile ranges (FOR INTERNAL USE ONLY).
*/
/**
* @typedef {Object} ol.DeviceOrientationOptions
* @property {boolean|undefined} tracking Tracking.

View File

@@ -1 +1 @@
@exportSymbol ol.Attribution
@exportClass ol.Attribution ol.AttributionOptions

View File

@@ -11,31 +11,31 @@ goog.require('ol.TileRange');
*
* source: new ol.source.OSM({
* attributions: [
* new ol.Attribution(
* 'All maps &copy; ' +
* '<a href="http://www.opencyclemap.org/">OpenCycleMap</a>'),
* new ol.Attribution({
* html: 'All maps &copy; ' +
* '<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).
* @param {ol.AttributionOptions} options Attribution options.
*/
ol.Attribution = function(html, opt_tileRanges) {
ol.Attribution = function(options) {
/**
* @private
* @type {string}
*/
this.html_ = html;
this.html_ = options.html;
/**
* @private
* @type {Object.<string, Array.<ol.TileRange>>}
*/
this.tileRanges_ = opt_tileRanges || null;
this.tileRanges_ = goog.isDef(options.tileRanges) ?
options.tileRanges : null;
};

View File

@@ -131,7 +131,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
}
}
});
return new ol.Attribution(html, tileRanges);
return new ol.Attribution({html: html, tileRanges: tileRanges});
});
this.setAttributions(attributions);

View File

@@ -14,9 +14,10 @@ goog.require('ol.source.XYZ');
ol.source.MapQuestOSM = function() {
var attributions = [
new ol.Attribution(
'Tiles Courtesy of ' +
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a>'),
new ol.Attribution({
html: 'Tiles Courtesy of ' +
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a>'
}),
ol.source.OSM.DATA_ATTRIBUTION
];
@@ -41,12 +42,14 @@ goog.inherits(ol.source.MapQuestOSM, ol.source.XYZ);
ol.source.MapQuestOpenAerial = function() {
var attributions = [
new ol.Attribution(
'Tiles Courtesy of ' +
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a>'),
new ol.Attribution(
'Portions Courtesy NASA/JPL-Caltech and ' +
'U.S. Depart. of Agriculture, Farm Service Agency')
new ol.Attribution({
html: 'Tiles Courtesy of ' +
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a>'
}),
new ol.Attribution({
html: 'Portions Courtesy NASA/JPL-Caltech and ' +
'U.S. Depart. of Agriculture, Farm Service Agency'
})
];
goog.base(this, {

View File

@@ -44,21 +44,24 @@ goog.inherits(ol.source.OSM, ol.source.XYZ);
* @const
* @type {ol.Attribution}
*/
ol.source.OSM.DATA_ATTRIBUTION = new ol.Attribution(
'Data &copy; <a href="http://www.openstreetmap.org/">OpenStreetMap</a> ' +
'contributors, ' +
'<a href="http://www.openstreetmap.org/copyright">ODbL</a>');
ol.source.OSM.DATA_ATTRIBUTION = new ol.Attribution({
html: 'Data &copy; ' +
'<a href="http://www.openstreetmap.org/">OpenStreetMap</a> ' +
'contributors, ' +
'<a href="http://www.openstreetmap.org/copyright">ODbL</a>'
});
/**
* @const
* @type {ol.Attribution}
*/
ol.source.OSM.TILE_ATTRIBUTION = new ol.Attribution(
'Tiles &copy; ' +
'<a href="http://www.openstreetmap.org/">OpenStreetMap</a> ' +
'contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC BY-SA</a>');
ol.source.OSM.TILE_ATTRIBUTION = new ol.Attribution({
html: 'Tiles &copy; ' +
'<a href="http://www.openstreetmap.org/">OpenStreetMap</a> ' +
'contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC BY-SA</a>'
});
/**

View File

@@ -114,8 +114,10 @@ goog.inherits(ol.source.Stamen, ol.source.XYZ);
* @const {Array.<ol.Attribution>}
*/
ol.source.Stamen.ATTRIBUTIONS = [
new ol.Attribution(
'Map tiles by <a href="http://stamen.com/">Stamen Design</a>, under ' +
'<a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.'),
new ol.Attribution({
html: 'Map tiles by <a href="http://stamen.com/">Stamen Design</a>, ' +
'under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY' +
' 3.0</a>.'
}),
ol.source.OSM.DATA_ATTRIBUTION
];

View File

@@ -113,7 +113,10 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
[tileGrid.getTileRangeForExtentAndZ(attributionExtent, z)];
}
this.setAttributions([
new ol.Attribution(tileJSON.attribution, tileRanges)
new ol.Attribution({
html: tileJSON.attribution,
tileRanges: tileRanges
})
]);
}