Merge pull request #947 from elemoine/attribution
Make ol.Attribution take an options object
This commit is contained in:
@@ -11,9 +11,10 @@ var map = new ol.Map({
|
|||||||
new ol.layer.TileLayer({
|
new ol.layer.TileLayer({
|
||||||
source: new ol.source.OSM({
|
source: new ol.source.OSM({
|
||||||
attributions: [
|
attributions: [
|
||||||
new ol.Attribution(
|
new ol.Attribution({
|
||||||
'All maps © ' +
|
html: 'All maps © ' +
|
||||||
'<a href="http://www.opencyclemap.org/">OpenCycleMap</a>'),
|
'<a href="http://www.opencyclemap.org/">OpenCycleMap</a>'
|
||||||
|
}),
|
||||||
ol.source.OSM.DATA_ATTRIBUTION
|
ol.source.OSM.DATA_ATTRIBUTION
|
||||||
],
|
],
|
||||||
url: 'http://{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png'
|
url: 'http://{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png'
|
||||||
|
|||||||
@@ -21,10 +21,12 @@ var layers = [
|
|||||||
source: new ol.source.TiledWMS({
|
source: new ol.source.TiledWMS({
|
||||||
url: 'http://wms.geo.admin.ch/',
|
url: 'http://wms.geo.admin.ch/',
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
attributions: [new ol.Attribution(
|
attributions: [new ol.Attribution({
|
||||||
'© ' +
|
html: '© ' +
|
||||||
'<a href="http://www.geo.admin.ch/internet/geoportal/en/home.html">' +
|
'<a href="http://www.geo.admin.ch/internet/geoportal/' +
|
||||||
'Pixelmap 1:1000000 / geo.admin.ch</a>')],
|
'en/home.html">' +
|
||||||
|
'Pixelmap 1:1000000 / geo.admin.ch</a>'
|
||||||
|
})],
|
||||||
params: {
|
params: {
|
||||||
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
|
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
|
||||||
'FORMAT': 'image/jpeg'
|
'FORMAT': 'image/jpeg'
|
||||||
@@ -36,10 +38,12 @@ var layers = [
|
|||||||
source: new ol.source.TiledWMS({
|
source: new ol.source.TiledWMS({
|
||||||
url: 'http://wms.geo.admin.ch/',
|
url: 'http://wms.geo.admin.ch/',
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
attributions: [new ol.Attribution(
|
attributions: [new ol.Attribution({
|
||||||
'© ' +
|
html: '© ' +
|
||||||
'<a href="http://www.geo.admin.ch/internet/geoportal/en/home.html">' +
|
'<a href="http://www.geo.admin.ch/internet/geoportal/' +
|
||||||
'National parks / geo.admin.ch</a>')],
|
'en/home.html">' +
|
||||||
|
'National parks / geo.admin.ch</a>'
|
||||||
|
})],
|
||||||
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
|
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
|
||||||
extent: extent
|
extent: extent
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -13,10 +13,12 @@ goog.require('ol.source.TiledWMS');
|
|||||||
var layers = [
|
var layers = [
|
||||||
new ol.layer.TileLayer({
|
new ol.layer.TileLayer({
|
||||||
source: new ol.source.TiledWMS({
|
source: new ol.source.TiledWMS({
|
||||||
attributions: [new ol.Attribution(
|
attributions: [new ol.Attribution({
|
||||||
'© ' +
|
html: '© ' +
|
||||||
'<a href="http://www.geo.admin.ch/internet/geoportal/en/home.html">' +
|
'<a href="http://www.geo.admin.ch/internet/geoportal/' +
|
||||||
'Pixelmap 1:1000000 / geo.admin.ch</a>')],
|
'en/home.html">' +
|
||||||
|
'Pixelmap 1:1000000 / geo.admin.ch</a>'
|
||||||
|
})],
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
params: {
|
params: {
|
||||||
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
|
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
|
||||||
@@ -27,10 +29,12 @@ var layers = [
|
|||||||
}),
|
}),
|
||||||
new ol.layer.ImageLayer({
|
new ol.layer.ImageLayer({
|
||||||
source: new ol.source.SingleImageWMS({
|
source: new ol.source.SingleImageWMS({
|
||||||
attributions: [new ol.Attribution(
|
attributions: [new ol.Attribution({
|
||||||
'© ' +
|
html: '© ' +
|
||||||
'<a href="http://www.geo.admin.ch/internet/geoportal/en/home.html">' +
|
'<a href="http://www.geo.admin.ch/internet/geoportal/' +
|
||||||
'National parks / geo.admin.ch</a>')],
|
'en/home.html">' +
|
||||||
|
'National parks / geo.admin.ch</a>'
|
||||||
|
})],
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
|
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
|
||||||
url: 'http://wms.geo.admin.ch/'
|
url: 'http://wms.geo.admin.ch/'
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ var layers = [
|
|||||||
source: new ol.source.SingleImageWMS({
|
source: new ol.source.SingleImageWMS({
|
||||||
url: 'http://wms.geo.admin.ch/',
|
url: 'http://wms.geo.admin.ch/',
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
attributions: [new ol.Attribution(
|
attributions: [new ol.Attribution({
|
||||||
'© ' +
|
html: '© ' +
|
||||||
'<a href="http://www.geo.admin.ch/internet/geoportal/en/home.html">' +
|
'<a href="http://www.geo.admin.ch/internet/geoportal/' +
|
||||||
'Pixelmap 1:1000000 / geo.admin.ch</a>')],
|
'en/home.html">' +
|
||||||
|
'Pixelmap 1:1000000 / geo.admin.ch</a>'
|
||||||
|
})],
|
||||||
params: {
|
params: {
|
||||||
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
|
'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale',
|
||||||
'FORMAT': 'image/jpeg'
|
'FORMAT': 'image/jpeg'
|
||||||
@@ -33,10 +35,12 @@ var layers = [
|
|||||||
source: new ol.source.SingleImageWMS({
|
source: new ol.source.SingleImageWMS({
|
||||||
url: 'http://wms.geo.admin.ch/',
|
url: 'http://wms.geo.admin.ch/',
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
attributions: [new ol.Attribution(
|
attributions: [new ol.Attribution({
|
||||||
'© ' +
|
html: '© ' +
|
||||||
'<a href="http://www.geo.admin.ch/internet/geoportal/en/home.html">' +
|
'<a href="http://www.geo.admin.ch/internet/geoportal/' +
|
||||||
'National parks / geo.admin.ch</a>')],
|
'en/home.html">' +
|
||||||
|
'National parks / geo.admin.ch</a>'
|
||||||
|
})],
|
||||||
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
|
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
|
||||||
extent: extent
|
extent: extent
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -51,10 +51,11 @@ xhr.onload = function() {
|
|||||||
'http://gpp3-wxs.ign.fr/static/logos/IGN/IGN.gif'
|
'http://gpp3-wxs.ign.fr/static/logos/IGN/IGN.gif'
|
||||||
];
|
];
|
||||||
|
|
||||||
var attribution = new ol.Attribution(
|
var attribution = new ol.Attribution({
|
||||||
'<a href="http://www.geoportail.fr/" target="_blank">' +
|
html: '<a href="http://www.geoportail.fr/" target="_blank">' +
|
||||||
'<img src="http://api.ign.fr/geoportail/api/js/latest/' +
|
'<img src="http://api.ign.fr/geoportail/api/js/latest/' +
|
||||||
'theme/geoportal/img/logo_gp.gif"></a>');
|
'theme/geoportal/img/logo_gp.gif"></a>'
|
||||||
|
});
|
||||||
|
|
||||||
var sourceOptions;
|
var sourceOptions;
|
||||||
var source;
|
var source;
|
||||||
|
|||||||
@@ -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
|
* @typedef {Object} ol.DeviceOrientationOptions
|
||||||
* @property {boolean|undefined} tracking Tracking.
|
* @property {boolean|undefined} tracking Tracking.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
@exportSymbol ol.Attribution
|
@exportClass ol.Attribution ol.AttributionOptions
|
||||||
|
|||||||
@@ -11,31 +11,31 @@ goog.require('ol.TileRange');
|
|||||||
*
|
*
|
||||||
* source: new ol.source.OSM({
|
* source: new ol.source.OSM({
|
||||||
* attributions: [
|
* attributions: [
|
||||||
* new ol.Attribution(
|
* new ol.Attribution({
|
||||||
* 'All maps © ' +
|
* html: 'All maps © ' +
|
||||||
* '<a href="http://www.opencyclemap.org/">OpenCycleMap</a>'),
|
* '<a href="http://www.opencyclemap.org/">OpenCycleMap</a>'
|
||||||
|
* }),
|
||||||
* ol.source.OSM.DATA_ATTRIBUTION
|
* ol.source.OSM.DATA_ATTRIBUTION
|
||||||
* ],
|
* ],
|
||||||
* ..
|
* ..
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {string} html The markup to use for display of the attribution.
|
* @param {ol.AttributionOptions} options Attribution options.
|
||||||
* @param {Object.<string, Array.<ol.TileRange>>=} opt_tileRanges Tile ranges
|
|
||||||
* (FOR INTERNAL USE ONLY).
|
|
||||||
*/
|
*/
|
||||||
ol.Attribution = function(html, opt_tileRanges) {
|
ol.Attribution = function(options) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.html_ = html;
|
this.html_ = options.html;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Object.<string, Array.<ol.TileRange>>}
|
* @type {Object.<string, Array.<ol.TileRange>>}
|
||||||
*/
|
*/
|
||||||
this.tileRanges_ = opt_tileRanges || null;
|
this.tileRanges_ = goog.isDef(options.tileRanges) ?
|
||||||
|
options.tileRanges : null;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
this.setAttributions(attributions);
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ goog.require('ol.source.XYZ');
|
|||||||
ol.source.MapQuestOSM = function() {
|
ol.source.MapQuestOSM = function() {
|
||||||
|
|
||||||
var attributions = [
|
var attributions = [
|
||||||
new ol.Attribution(
|
new ol.Attribution({
|
||||||
'Tiles Courtesy of ' +
|
html: 'Tiles Courtesy of ' +
|
||||||
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a>'),
|
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a>'
|
||||||
|
}),
|
||||||
ol.source.OSM.DATA_ATTRIBUTION
|
ol.source.OSM.DATA_ATTRIBUTION
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -41,12 +42,14 @@ goog.inherits(ol.source.MapQuestOSM, ol.source.XYZ);
|
|||||||
ol.source.MapQuestOpenAerial = function() {
|
ol.source.MapQuestOpenAerial = function() {
|
||||||
|
|
||||||
var attributions = [
|
var attributions = [
|
||||||
new ol.Attribution(
|
new ol.Attribution({
|
||||||
'Tiles Courtesy of ' +
|
html: 'Tiles Courtesy of ' +
|
||||||
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a>'),
|
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a>'
|
||||||
new ol.Attribution(
|
}),
|
||||||
'Portions Courtesy NASA/JPL-Caltech and ' +
|
new ol.Attribution({
|
||||||
'U.S. Depart. of Agriculture, Farm Service Agency')
|
html: 'Portions Courtesy NASA/JPL-Caltech and ' +
|
||||||
|
'U.S. Depart. of Agriculture, Farm Service Agency'
|
||||||
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
|
|||||||
@@ -44,21 +44,24 @@ goog.inherits(ol.source.OSM, ol.source.XYZ);
|
|||||||
* @const
|
* @const
|
||||||
* @type {ol.Attribution}
|
* @type {ol.Attribution}
|
||||||
*/
|
*/
|
||||||
ol.source.OSM.DATA_ATTRIBUTION = new ol.Attribution(
|
ol.source.OSM.DATA_ATTRIBUTION = new ol.Attribution({
|
||||||
'Data © <a href="http://www.openstreetmap.org/">OpenStreetMap</a> ' +
|
html: 'Data © ' +
|
||||||
'contributors, ' +
|
'<a href="http://www.openstreetmap.org/">OpenStreetMap</a> ' +
|
||||||
'<a href="http://www.openstreetmap.org/copyright">ODbL</a>');
|
'contributors, ' +
|
||||||
|
'<a href="http://www.openstreetmap.org/copyright">ODbL</a>'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.Attribution}
|
* @type {ol.Attribution}
|
||||||
*/
|
*/
|
||||||
ol.source.OSM.TILE_ATTRIBUTION = new ol.Attribution(
|
ol.source.OSM.TILE_ATTRIBUTION = new ol.Attribution({
|
||||||
'Tiles © ' +
|
html: 'Tiles © ' +
|
||||||
'<a href="http://www.openstreetmap.org/">OpenStreetMap</a> ' +
|
'<a href="http://www.openstreetmap.org/">OpenStreetMap</a> ' +
|
||||||
'contributors, ' +
|
'contributors, ' +
|
||||||
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC BY-SA</a>');
|
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC BY-SA</a>'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -114,8 +114,10 @@ goog.inherits(ol.source.Stamen, ol.source.XYZ);
|
|||||||
* @const {Array.<ol.Attribution>}
|
* @const {Array.<ol.Attribution>}
|
||||||
*/
|
*/
|
||||||
ol.source.Stamen.ATTRIBUTIONS = [
|
ol.source.Stamen.ATTRIBUTIONS = [
|
||||||
new ol.Attribution(
|
new ol.Attribution({
|
||||||
'Map tiles by <a href="http://stamen.com/">Stamen Design</a>, under ' +
|
html: 'Map tiles by <a href="http://stamen.com/">Stamen Design</a>, ' +
|
||||||
'<a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.'),
|
'under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY' +
|
||||||
|
' 3.0</a>.'
|
||||||
|
}),
|
||||||
ol.source.OSM.DATA_ATTRIBUTION
|
ol.source.OSM.DATA_ATTRIBUTION
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -113,7 +113,10 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
|
|||||||
[tileGrid.getTileRangeForExtentAndZ(attributionExtent, z)];
|
[tileGrid.getTileRangeForExtentAndZ(attributionExtent, z)];
|
||||||
}
|
}
|
||||||
this.setAttributions([
|
this.setAttributions([
|
||||||
new ol.Attribution(tileJSON.attribution, tileRanges)
|
new ol.Attribution({
|
||||||
|
html: tileJSON.attribution,
|
||||||
|
tileRanges: tileRanges
|
||||||
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user