From 42cf5f8511f10b69528e9a9febc99b9bd99ce044 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 25 Feb 2018 08:23:05 -0700 Subject: [PATCH] Named exports from ol/source/OSM --- examples/igc.js | 4 ++-- examples/localized-openstreetmap.js | 6 +++--- src/ol/source/OSM.js | 26 ++++++++++++++------------ src/ol/source/Stamen.js | 4 ++-- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/examples/igc.js b/examples/igc.js index 275a736ebd..1f993eb506 100644 --- a/examples/igc.js +++ b/examples/igc.js @@ -7,7 +7,7 @@ import LineString from '../src/ol/geom/LineString.js'; import Point from '../src/ol/geom/Point.js'; import TileLayer from '../src/ol/layer/Tile.js'; import VectorLayer from '../src/ol/layer/Vector.js'; -import OSM from '../src/ol/source/OSM.js'; +import OSM, {ATTRIBUTION} from '../src/ol/source/OSM.js'; import VectorSource from '../src/ol/source/Vector.js'; import CircleStyle from '../src/ol/style/Circle.js'; import Fill from '../src/ol/style/Fill.js'; @@ -86,7 +86,7 @@ const map = new Map({ source: new OSM({ attributions: [ 'All maps © OpenCycleMap', - OSM.ATTRIBUTION + ATTRIBUTION ], url: 'https://{a-c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png' + '?apikey=0e6fc415256d4fbb9b5166a718591d71' diff --git a/examples/localized-openstreetmap.js b/examples/localized-openstreetmap.js index cea87b8b9d..562cfcf540 100644 --- a/examples/localized-openstreetmap.js +++ b/examples/localized-openstreetmap.js @@ -2,14 +2,14 @@ import Map from '../src/ol/Map.js'; import View from '../src/ol/View.js'; import {defaults as defaultControls} from '../src/ol/control.js'; import TileLayer from '../src/ol/layer/Tile.js'; -import OSM from '../src/ol/source/OSM.js'; +import OSM, {ATTRIBUTION} from '../src/ol/source/OSM.js'; const openCycleMapLayer = new TileLayer({ source: new OSM({ attributions: [ 'All maps © OpenCycleMap', - OSM.ATTRIBUTION + ATTRIBUTION ], url: 'https://{a-c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png' + '?apikey=0e6fc415256d4fbb9b5166a718591d71' @@ -20,7 +20,7 @@ const openSeaMapLayer = new TileLayer({ source: new OSM({ attributions: [ 'All maps © OpenSeaMap', - OSM.ATTRIBUTION + ATTRIBUTION ], opaque: false, url: 'https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png' diff --git a/src/ol/source/OSM.js b/src/ol/source/OSM.js index f934d0762f..a583bc5ffc 100644 --- a/src/ol/source/OSM.js +++ b/src/ol/source/OSM.js @@ -4,6 +4,19 @@ import {inherits} from '../index.js'; import XYZ from '../source/XYZ.js'; + +/** + * The attribution containing a link to the OpenStreetMap Copyright and License + * page. + * @const + * @type {string} + * @api + */ +export const ATTRIBUTION = '© ' + + 'OpenStreetMap ' + + 'contributors.'; + + /** * @classdesc * Layer source for the OpenStreetMap tile server. @@ -21,7 +34,7 @@ const OSM = function(opt_options) { if (options.attributions !== undefined) { attributions = options.attributions; } else { - attributions = [OSM.ATTRIBUTION]; + attributions = [ATTRIBUTION]; } const crossOrigin = options.crossOrigin !== undefined ? @@ -46,15 +59,4 @@ const OSM = function(opt_options) { inherits(OSM, XYZ); - -/** - * The attribution containing a link to the OpenStreetMap Copyright and License - * page. - * @const - * @type {string} - * @api - */ -OSM.ATTRIBUTION = '© ' + - 'OpenStreetMap ' + - 'contributors.'; export default OSM; diff --git a/src/ol/source/Stamen.js b/src/ol/source/Stamen.js index d15cfe7933..a691162587 100644 --- a/src/ol/source/Stamen.js +++ b/src/ol/source/Stamen.js @@ -2,7 +2,7 @@ * @module ol/source/Stamen */ import {inherits} from '../index.js'; -import OSM from '../source/OSM.js'; +import {ATTRIBUTION as OSM_ATTRIBUTION} from '../source/OSM.js'; import XYZ from '../source/XYZ.js'; @@ -14,7 +14,7 @@ const ATTRIBUTIONS = [ 'Map tiles by Stamen Design, ' + 'under CC BY' + ' 3.0.', - OSM.ATTRIBUTION + OSM_ATTRIBUTION ];