-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Handle new Stadia vendor type and create XYZ sources * Attempt update of ol, ol-ext, and ol-layerswitcher * fix imports on edit bar * Rename ol5support folder, modify EditBar * Testing better means of overriding code * Revert "Testing better means of overriding code" This reverts commit 39b1a09. * Revert "Rename ol5support folder, modify EditBar" This reverts commit 4346c59. * Revert "fix imports on edit bar" This reverts commit c584d4c. * Revert "Attempt update of ol, ol-ext, and ol-layerswitcher" This reverts commit 6f473bf. * Add StadiaMaps support for OL2 canvas * Rename function
- Loading branch information
Showing
3 changed files
with
183 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
nunaliit2-js/src/main/nunaliit-es6/src/n2es6/n2mapModule/N2StadiaMapsFactory.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* @module n2es6/N2StadiaMapsFactory | ||
*/ | ||
|
||
import XYZ from 'ol/source/XYZ'; | ||
|
||
const STADIA_MAPS_URL_TEMPLATE = (layer, pixelRatio, extension) => { | ||
return `https://tiles.stadiamaps.com/tiles/${layer}/{z}/{x}/{y}${pixelRatio > 1 ? "@"+pixelRatio+"x" : ""}.${extension}` | ||
} | ||
|
||
const N2StadiaMapsFactory = (layerName) => { | ||
if (layerName === "alidade_smooth") { | ||
return new XYZ({ | ||
url: STADIA_MAPS_URL_TEMPLATE(layerName, 2, "png"), | ||
attributions: [ | ||
'© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>', | ||
'© <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>', | ||
'© <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>' | ||
], | ||
tilePixelRatio: 2, | ||
maxZoom: 20 | ||
}) | ||
} | ||
else if (layerName === "alidade_smooth_dark") { | ||
return new XYZ({ | ||
url: STADIA_MAPS_URL_TEMPLATE(layerName, 2, "png"), | ||
attributions: [ | ||
'© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>', | ||
'© <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>', | ||
'© <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>' | ||
], | ||
tilePixelRatio: 2, | ||
maxZoom: 20 | ||
}) | ||
} | ||
else if (layerName === "outdoors") { | ||
return new XYZ({ | ||
url: STADIA_MAPS_URL_TEMPLATE(layerName, 2, "png"), | ||
attributions: [ | ||
'© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>', | ||
'© <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>', | ||
'© <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>' | ||
], | ||
tilePixelRatio: 2, | ||
maxZoom: 20 | ||
}) | ||
} | ||
else if (layerName === "stamen_toner") { | ||
return new XYZ({ | ||
url: STADIA_MAPS_URL_TEMPLATE(layerName, 2, "png"), | ||
attributions: [ | ||
'© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>', | ||
'© <a href="https://stamen.com/" target="_blank">Stamen Design</a>', | ||
'© <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>', | ||
'© <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>' | ||
], | ||
tilePixelRatio: 2, | ||
maxZoom: 20 | ||
}) | ||
} | ||
else if (layerName === "stamen_terrain") { | ||
return new XYZ({ | ||
url: STADIA_MAPS_URL_TEMPLATE(layerName, 2, "png"), | ||
attributions: [ | ||
'© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>', | ||
'© <a href="https://stamen.com/" target="_blank">Stamen Design</a>', | ||
'© <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>', | ||
'© <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>' | ||
], | ||
tilePixelRatio: 2, | ||
maxZoom: 20 | ||
}) | ||
} | ||
else if (layerName === "stamen_watercolor") { | ||
return new XYZ({ | ||
url: STADIA_MAPS_URL_TEMPLATE(layerName, 1, "jpg"), | ||
attributions: [ | ||
'© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>', | ||
'© <a href="https://stamen.com/" target="_blank">Stamen Design</a>', | ||
'© <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>', | ||
'© <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>' | ||
], | ||
tilePixelRatio: 1, | ||
maxZoom: 16 | ||
}) | ||
} | ||
else if (layerName === "osm_bright") { | ||
return new XYZ({ | ||
url: STADIA_MAPS_URL_TEMPLATE(layerName, 2, "png"), | ||
attributions: [ | ||
'© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>', | ||
'© <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>', | ||
'© <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>' | ||
], | ||
tilePixelRatio: 2, | ||
maxZoom: 20 | ||
}) | ||
} | ||
else { | ||
$n2.reportErrorForced(`${layerName} is not an accepted/implemented layer name for Stadia backgrounds.`) | ||
} | ||
} | ||
|
||
export default N2StadiaMapsFactory; |