From b94b8cc40df10d68e2e7465fded8f737a3b8f21b Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 8 Oct 2017 15:07:09 -0600 Subject: [PATCH] Add deprecation notes for ol.Attribution --- changelog/upgrade-notes.md | 30 ++++++++++++++++++++++++++++++ src/ol/attribution.js | 1 + src/ol/source/source.js | 1 + 3 files changed, 32 insertions(+) diff --git a/changelog/upgrade-notes.md b/changelog/upgrade-notes.md index 95108b982b..f88bca463a 100644 --- a/changelog/upgrade-notes.md +++ b/changelog/upgrade-notes.md @@ -2,6 +2,36 @@ ### Next Release +#### Deprecation of `ol.Attribution` + +`ol.Attribution` is deprecated and will be removed in the next major version. Instead, you can construct a source with a string attribution or an array of strings. For dynamic attributions, you can provide a function that gets called with the current frame state. + +Before: +```js +var source = new ol.source.XYZ({ + attributions: [ + new ol.Attribution({html: 'some attribution'}) + ] +}); +``` + +After: +```js +var source = new ol.source.XYZ({ + attributions: 'some attribution' +}); +``` + +In addition to passing a string or an array of strings for the `attributions` option, you can also pass a function that will get called with the current frame state. +```js +var source = new ol.source.XYZ({ + attributions: function(frameState) { + // inspect the frame state and return attributions + return 'some attribution'; // or ['multiple', 'attributions'] or null + } +}); +``` + ### v4.4.0 #### Behavior change for polygon labels diff --git a/src/ol/attribution.js b/src/ol/attribution.js index 4cc0d7e9e0..161d7e46d9 100644 --- a/src/ol/attribution.js +++ b/src/ol/attribution.js @@ -22,6 +22,7 @@ goog.require('ol.tilegrid'); * .. * * @constructor + * @deprecated This class is deprecated and will removed in the next major release. * @param {olx.AttributionOptions} options Attribution options. * @struct * @api diff --git a/src/ol/source/source.js b/src/ol/source/source.js index 2f37960fd3..9e1fdf1ce3 100644 --- a/src/ol/source/source.js +++ b/src/ol/source/source.js @@ -67,6 +67,7 @@ ol.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). */