From 818894bb56557dfa23b432b93bc0d928098b4512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Fri, 30 Aug 2013 16:46:51 +0200 Subject: [PATCH 1/3] ol.Attribution is a single-arg constructor --- src/objectliterals.jsdoc | 7 +++++++ src/ol/attribution.exports | 2 +- src/ol/attribution.js | 18 +++++++++--------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 8b94acbd1f..f4775394c6 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -1,3 +1,10 @@ +/** + * @typedef {Object} ol.AttributionOptions + * @property {string} html HTML markup for this attribution. + * @property {Object.>|undefined} tileRanges + * Tile ranges (FOR INTERNAL USE ONLY). + */ + /** * @typedef {Object} ol.DeviceOrientationOptions * @property {boolean|undefined} tracking Tracking. diff --git a/src/ol/attribution.exports b/src/ol/attribution.exports index 053c0abeae..27673d4985 100644 --- a/src/ol/attribution.exports +++ b/src/ol/attribution.exports @@ -1 +1 @@ -@exportSymbol ol.Attribution +@exportClass ol.Attribution ol.AttributionOptions diff --git a/src/ol/attribution.js b/src/ol/attribution.js index 81a88007be..95bc352e60 100644 --- a/src/ol/attribution.js +++ b/src/ol/attribution.js @@ -11,31 +11,31 @@ goog.require('ol.TileRange'); * * source: new ol.source.OSM({ * attributions: [ - * new ol.Attribution( - * 'All maps © ' + - * 'OpenCycleMap'), + * new ol.Attribution({ + * html: 'All maps © ' + + * 'OpenCycleMap' + * }), * ol.source.OSM.DATA_ATTRIBUTION * ], * .. * * @constructor - * @param {string} html The markup to use for display of the attribution. - * @param {Object.>=} 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.>} */ - this.tileRanges_ = opt_tileRanges || null; + this.tileRanges_ = goog.isDef(options.tileRanges) ? + options.tileRanges : null; }; From 38ab64c3c384011b006e7ba66a10b3e1ef19ca3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Fri, 30 Aug 2013 16:47:42 +0200 Subject: [PATCH 2/3] Adapt sources to new signature for ol.Attribution --- src/ol/source/bingmapssource.js | 2 +- src/ol/source/mapquestsource.js | 21 ++++++++++++--------- src/ol/source/osmsource.js | 21 ++++++++++++--------- src/ol/source/stamensource.js | 8 +++++--- src/ol/source/tilejsonsource.js | 5 ++++- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/ol/source/bingmapssource.js b/src/ol/source/bingmapssource.js index 9882130e9c..226138140f 100644 --- a/src/ol/source/bingmapssource.js +++ b/src/ol/source/bingmapssource.js @@ -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); diff --git a/src/ol/source/mapquestsource.js b/src/ol/source/mapquestsource.js index 2263523fc6..c7b2bce931 100644 --- a/src/ol/source/mapquestsource.js +++ b/src/ol/source/mapquestsource.js @@ -14,9 +14,10 @@ goog.require('ol.source.XYZ'); ol.source.MapQuestOSM = function() { var attributions = [ - new ol.Attribution( - 'Tiles Courtesy of ' + - 'MapQuest'), + new ol.Attribution({ + html: 'Tiles Courtesy of ' + + 'MapQuest' + }), 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 ' + - 'MapQuest'), - new ol.Attribution( - 'Portions Courtesy NASA/JPL-Caltech and ' + - 'U.S. Depart. of Agriculture, Farm Service Agency') + new ol.Attribution({ + html: 'Tiles Courtesy of ' + + 'MapQuest' + }), + new ol.Attribution({ + html: 'Portions Courtesy NASA/JPL-Caltech and ' + + 'U.S. Depart. of Agriculture, Farm Service Agency' + }) ]; goog.base(this, { diff --git a/src/ol/source/osmsource.js b/src/ol/source/osmsource.js index 4f3e88dd19..cc759a3653 100644 --- a/src/ol/source/osmsource.js +++ b/src/ol/source/osmsource.js @@ -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 © OpenStreetMap ' + - 'contributors, ' + - 'ODbL'); +ol.source.OSM.DATA_ATTRIBUTION = new ol.Attribution({ + html: 'Data © ' + + 'OpenStreetMap ' + + 'contributors, ' + + 'ODbL' +}); /** * @const * @type {ol.Attribution} */ -ol.source.OSM.TILE_ATTRIBUTION = new ol.Attribution( - 'Tiles © ' + - 'OpenStreetMap ' + - 'contributors, ' + - 'CC BY-SA'); +ol.source.OSM.TILE_ATTRIBUTION = new ol.Attribution({ + html: 'Tiles © ' + + 'OpenStreetMap ' + + 'contributors, ' + + 'CC BY-SA' +}); /** diff --git a/src/ol/source/stamensource.js b/src/ol/source/stamensource.js index 01a856201d..1486aa0d98 100644 --- a/src/ol/source/stamensource.js +++ b/src/ol/source/stamensource.js @@ -114,8 +114,10 @@ goog.inherits(ol.source.Stamen, ol.source.XYZ); * @const {Array.} */ ol.source.Stamen.ATTRIBUTIONS = [ - new ol.Attribution( - 'Map tiles by Stamen Design, under ' + - 'CC BY 3.0.'), + new ol.Attribution({ + html: 'Map tiles by Stamen Design, ' + + 'under CC BY' + + ' 3.0.' + }), ol.source.OSM.DATA_ATTRIBUTION ]; diff --git a/src/ol/source/tilejsonsource.js b/src/ol/source/tilejsonsource.js index 42c1e97a4e..9d01f57acb 100644 --- a/src/ol/source/tilejsonsource.js +++ b/src/ol/source/tilejsonsource.js @@ -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 + }) ]); } From 729039ba043c9293df7c09a42dc7c655ca0475ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Fri, 30 Aug 2013 16:48:25 +0200 Subject: [PATCH 3/3] Adapt examples to new signature for ol.Attribution --- examples/localized-openstreetmap.js | 7 ++++--- examples/wms-custom-proj.js | 20 ++++++++++++-------- examples/wms-no-proj.js | 20 ++++++++++++-------- examples/wms-single-image-custom-proj.js | 20 ++++++++++++-------- examples/wmts-ign.js | 9 +++++---- 5 files changed, 45 insertions(+), 31 deletions(-) diff --git a/examples/localized-openstreetmap.js b/examples/localized-openstreetmap.js index e8053c83d1..21571eb09a 100644 --- a/examples/localized-openstreetmap.js +++ b/examples/localized-openstreetmap.js @@ -11,9 +11,10 @@ var map = new ol.Map({ new ol.layer.TileLayer({ source: new ol.source.OSM({ attributions: [ - new ol.Attribution( - 'All maps © ' + - 'OpenCycleMap'), + new ol.Attribution({ + html: 'All maps © ' + + 'OpenCycleMap' + }), ol.source.OSM.DATA_ATTRIBUTION ], url: 'http://{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png' diff --git a/examples/wms-custom-proj.js b/examples/wms-custom-proj.js index 2d71383205..7926d4ec7e 100644 --- a/examples/wms-custom-proj.js +++ b/examples/wms-custom-proj.js @@ -21,10 +21,12 @@ var layers = [ source: new ol.source.TiledWMS({ url: 'http://wms.geo.admin.ch/', crossOrigin: 'anonymous', - attributions: [new ol.Attribution( - '© ' + - '' + - 'Pixelmap 1:1000000 / geo.admin.ch')], + attributions: [new ol.Attribution({ + html: '© ' + + '' + + 'Pixelmap 1:1000000 / geo.admin.ch' + })], params: { 'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale', 'FORMAT': 'image/jpeg' @@ -36,10 +38,12 @@ var layers = [ source: new ol.source.TiledWMS({ url: 'http://wms.geo.admin.ch/', crossOrigin: 'anonymous', - attributions: [new ol.Attribution( - '© ' + - '' + - 'National parks / geo.admin.ch')], + attributions: [new ol.Attribution({ + html: '© ' + + '' + + 'National parks / geo.admin.ch' + })], params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'}, extent: extent }) diff --git a/examples/wms-no-proj.js b/examples/wms-no-proj.js index 1bb50d5454..4d5db23199 100644 --- a/examples/wms-no-proj.js +++ b/examples/wms-no-proj.js @@ -13,10 +13,12 @@ goog.require('ol.source.TiledWMS'); var layers = [ new ol.layer.TileLayer({ source: new ol.source.TiledWMS({ - attributions: [new ol.Attribution( - '© ' + - '' + - 'Pixelmap 1:1000000 / geo.admin.ch')], + attributions: [new ol.Attribution({ + html: '© ' + + '' + + 'Pixelmap 1:1000000 / geo.admin.ch' + })], crossOrigin: 'anonymous', params: { 'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale', @@ -27,10 +29,12 @@ var layers = [ }), new ol.layer.ImageLayer({ source: new ol.source.SingleImageWMS({ - attributions: [new ol.Attribution( - '© ' + - '' + - 'National parks / geo.admin.ch')], + attributions: [new ol.Attribution({ + html: '© ' + + '' + + 'National parks / geo.admin.ch' + })], crossOrigin: 'anonymous', params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'}, url: 'http://wms.geo.admin.ch/' diff --git a/examples/wms-single-image-custom-proj.js b/examples/wms-single-image-custom-proj.js index 8e4ed4ce4f..6e97b8cab3 100644 --- a/examples/wms-single-image-custom-proj.js +++ b/examples/wms-single-image-custom-proj.js @@ -18,10 +18,12 @@ var layers = [ source: new ol.source.SingleImageWMS({ url: 'http://wms.geo.admin.ch/', crossOrigin: 'anonymous', - attributions: [new ol.Attribution( - '© ' + - '' + - 'Pixelmap 1:1000000 / geo.admin.ch')], + attributions: [new ol.Attribution({ + html: '© ' + + '' + + 'Pixelmap 1:1000000 / geo.admin.ch' + })], params: { 'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale', 'FORMAT': 'image/jpeg' @@ -33,10 +35,12 @@ var layers = [ source: new ol.source.SingleImageWMS({ url: 'http://wms.geo.admin.ch/', crossOrigin: 'anonymous', - attributions: [new ol.Attribution( - '© ' + - '' + - 'National parks / geo.admin.ch')], + attributions: [new ol.Attribution({ + html: '© ' + + '' + + 'National parks / geo.admin.ch' + })], params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'}, extent: extent }) diff --git a/examples/wmts-ign.js b/examples/wmts-ign.js index 7a0f17c43e..d54d2730bb 100644 --- a/examples/wmts-ign.js +++ b/examples/wmts-ign.js @@ -51,10 +51,11 @@ xhr.onload = function() { 'http://gpp3-wxs.ign.fr/static/logos/IGN/IGN.gif' ]; - var attribution = new ol.Attribution( - '' + - ''); + var attribution = new ol.Attribution({ + html: '' + + '' + }); var sourceOptions; var source;