From 1b70646b9416b500e67d736a584e0ac36756108d Mon Sep 17 00:00:00 2001 From: Mary Salvi Date: Thu, 23 Sep 2021 16:03:39 -0400 Subject: [PATCH 1/3] adds basemaps from Carto --- src/osmLayer.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/osmLayer.js b/src/osmLayer.js index 22a4757c09..0f3ff4ec49 100644 --- a/src/osmLayer.js +++ b/src/osmLayer.js @@ -131,6 +131,9 @@ let StamenAttribution = 'Map tiles by Stamen ' + 'CC BY 3.0. Data by OpenStreetMap' + ', under ODbL.'; +/* Per Carto's website regarding basemap attribution: https://carto.com/help/working-with-data/attribution/#basemaps */ +let CartoAttribution = ' Carto ' + 'Contributors OpenStreetMap' + /** * This is a list of known tile sources. It can be added to via * `geo.osmLayer.tilesource[] = `, where the object has `url`, @@ -139,6 +142,18 @@ let StamenAttribution = 'Map tiles by Stamen ' + * @type {object} */ osmLayer.tileSources = { + 'darkMatter-with-labels': { + url: ' https://{s}.basemaps.cartocdn.com/rastertiles/dark_all/{z}/{x}/{y}.png', + attribution: CartoAttribution, + minLevel: 0, + maxLevel: 18 + }, + 'darkMatter-without-labels': { + url: 'https://{s}.basemaps.cartocdn.com/rastertiles/dark_nolabels/{z}/{x}/{y}.png', + attribution: CartoAttribution, + minLevel: 0, + maxLevel: 18 + }, 'nationalmap-satellite': { url: 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}', attribution: 'Tile data from USGS', @@ -153,6 +168,18 @@ osmLayer.tileSources = { minLevel: 0, maxLevel: 19 }, + 'positron-with-labels': { + url: 'https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png', + attribution: CartoAttribution, + minLevel: 0, + maxLevel: 18 + }, + 'positron-without-labels': { + url: 'https://{s}.basemaps.cartocdn.com/rastertiles/light_nolabels/{z}/{x}/{y}.png', + attribution: CartoAttribution, + minLevel: 0, + maxLevel: 18 + }, 'stamen-terrain': { url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png', attribution: StamenAttribution, @@ -181,6 +208,18 @@ osmLayer.tileSources = { minLevel: 0, maxLevel: 20 }, + 'voyager-with-labels': { + url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}.png', + attribution: CartoAttribution, + minLevel: 0, + maxLevel: 18 + }, + 'voyager-without-layers': { + url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager_nolabels/{z}/{x}/{y}.png', + attribution: CartoAttribution, + minLevel: 0, + maxLevel: 18 + }, 'wikimedia': { url: 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png', attribution: 'Wikimedia maps | Map data © OpenStreetMap contributors', From 0b2c714dd4011ba217a9dbae34dbec4e51089cdd Mon Sep 17 00:00:00 2001 From: Mary Salvi Date: Mon, 27 Sep 2021 14:28:06 -0400 Subject: [PATCH 2/3] updates example and adds name to layer def. --- examples/measure/index.pug | 8 -------- examples/measure/main.js | 12 +++++++++++- src/osmLayer.js | 19 ++++++++++++++++--- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/examples/measure/index.pug b/examples/measure/index.pug index 0f451f50a5..d6af56cddc 100644 --- a/examples/measure/index.pug +++ b/examples/measure/index.pug @@ -6,15 +6,7 @@ block append mainContent .form-group label(for='basemap') Base map select#basemap(param-name='basemap', placeholder='stamen-toner-lite') - option(value='stamen-toner-lite') Stamen Toner Lite - option(value='osm') OpenStreetMap - option(value='nationalmap-satellite') National Map Satellite - option(value='stamen-terrain') Stamen Terrain - option(value='stamen-terrain-background') Stamen Terrain Background - option(value='stamen-toner') Stamen Toner - option(value='wikimedia') Wikimedia option(value='custom') Custom - option(value='false') None button#hide(title='Hide the control panel') Hide input#mapurl.hidden(param-name='mapurl') .form-group.annotationtype(title='Select the type of annotation to add.') diff --git a/examples/measure/main.js b/examples/measure/main.js index 69c30da3db..691fd53157 100644 --- a/examples/measure/main.js +++ b/examples/measure/main.js @@ -47,9 +47,19 @@ if (query.extra) { // Add a blank tile for removing the map geo.osmLayer.tileSources['false'] = { url: '/data/white.jpg', - attribution: '' + attribution: '', + name: 'None' }; +// Fill select drop down +var options = geo.osmLayer.tileSources; +for (const option in options) { + var newOption = document.createElement('option'); + newOption.value = option; + newOption.text = options[option].name ? options[option].name : option; + document.getElementById('basemap').appendChild(newOption); +} + var map, mapLayer, layer, fromButtonSelect, fromGeojsonUpdate; // Set controls based on query parameters diff --git a/src/osmLayer.js b/src/osmLayer.js index 0f3ff4ec49..3413c370ea 100644 --- a/src/osmLayer.js +++ b/src/osmLayer.js @@ -132,7 +132,7 @@ let StamenAttribution = 'Map tiles by Stamen ' + ', under ODbL.'; /* Per Carto's website regarding basemap attribution: https://carto.com/help/working-with-data/attribution/#basemaps */ -let CartoAttribution = ' Carto ' + 'Contributors OpenStreetMap' +let CartoAttribution = ' Carto ' + 'Contributors OpenStreetMap'; /** * This is a list of known tile sources. It can be added to via @@ -142,21 +142,24 @@ let CartoAttribution = ' Carto ' + 'Contributors * @type {object} */ osmLayer.tileSources = { - 'darkMatter-with-labels': { + 'dark-matter-with-labels': { url: ' https://{s}.basemaps.cartocdn.com/rastertiles/dark_all/{z}/{x}/{y}.png', attribution: CartoAttribution, + name: 'Dark Matter With Labels', minLevel: 0, maxLevel: 18 }, - 'darkMatter-without-labels': { + 'dark-matter-without-labels': { url: 'https://{s}.basemaps.cartocdn.com/rastertiles/dark_nolabels/{z}/{x}/{y}.png', attribution: CartoAttribution, + name: 'Dark Matter Without Labels', minLevel: 0, maxLevel: 18 }, 'nationalmap-satellite': { url: 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}', attribution: 'Tile data from USGS', + name:'National Map Satellite', minLevel: 0, maxLevel: 16 }, @@ -164,6 +167,7 @@ osmLayer.tileSources = { url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', attribution: 'Tile data © ' + 'OpenStreetMap contributors', + name:'OpenStreetMap', subdomains: 'abc', minLevel: 0, maxLevel: 19 @@ -171,18 +175,21 @@ osmLayer.tileSources = { 'positron-with-labels': { url: 'https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png', attribution: CartoAttribution, + name:'Positron With Labels', minLevel: 0, maxLevel: 18 }, 'positron-without-labels': { url: 'https://{s}.basemaps.cartocdn.com/rastertiles/light_nolabels/{z}/{x}/{y}.png', attribution: CartoAttribution, + name:'Positron Without Labels', minLevel: 0, maxLevel: 18 }, 'stamen-terrain': { url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png', attribution: StamenAttribution, + name:'Stamen Terrain', subdomains: 'abcd', minLevel: 0, maxLevel: 14 @@ -190,6 +197,7 @@ osmLayer.tileSources = { 'stamen-terrain-background': { url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/terrain-background/{z}/{x}/{y}.png', attribution: StamenAttribution, + name:'Stamen Terrain Background', subdomains: 'abcd', minLevel: 0, maxLevel: 14 @@ -197,6 +205,7 @@ osmLayer.tileSources = { 'stamen-toner': { url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/toner/{z}/{x}/{y}.png', attribution: StamenAttribution, + name:'Stamen Toner', subdomains: 'abcd', minLevel: 0, maxLevel: 20 @@ -204,6 +213,7 @@ osmLayer.tileSources = { 'stamen-toner-lite': { url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.png', attribution: StamenAttribution, + name:'Stamen Toner Lite', subdomains: 'abcd', minLevel: 0, maxLevel: 20 @@ -211,18 +221,21 @@ osmLayer.tileSources = { 'voyager-with-labels': { url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}.png', attribution: CartoAttribution, + name:'Voyager With Labels', minLevel: 0, maxLevel: 18 }, 'voyager-without-layers': { url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager_nolabels/{z}/{x}/{y}.png', attribution: CartoAttribution, + name:'Voyager Without Layers', minLevel: 0, maxLevel: 18 }, 'wikimedia': { url: 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png', attribution: 'Wikimedia maps | Map data © OpenStreetMap contributors', + name:'Wikimedia', minLevel: 0, maxLevel: 19 } From 9d9683b24ebfed28862026e266bd32d7af14013c Mon Sep 17 00:00:00 2001 From: Mary Salvi Date: Mon, 27 Sep 2021 14:58:32 -0400 Subject: [PATCH 3/3] updates carto names in def --- src/osmLayer.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/osmLayer.js b/src/osmLayer.js index 3413c370ea..de04a6e556 100644 --- a/src/osmLayer.js +++ b/src/osmLayer.js @@ -145,14 +145,14 @@ osmLayer.tileSources = { 'dark-matter-with-labels': { url: ' https://{s}.basemaps.cartocdn.com/rastertiles/dark_all/{z}/{x}/{y}.png', attribution: CartoAttribution, - name: 'Dark Matter With Labels', + name: 'Carto Dark Matter With Labels', minLevel: 0, maxLevel: 18 }, 'dark-matter-without-labels': { url: 'https://{s}.basemaps.cartocdn.com/rastertiles/dark_nolabels/{z}/{x}/{y}.png', attribution: CartoAttribution, - name: 'Dark Matter Without Labels', + name: 'Carto Dark Matter Without Labels', minLevel: 0, maxLevel: 18 }, @@ -175,14 +175,14 @@ osmLayer.tileSources = { 'positron-with-labels': { url: 'https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png', attribution: CartoAttribution, - name:'Positron With Labels', + name:'Carto Positron With Labels', minLevel: 0, maxLevel: 18 }, 'positron-without-labels': { url: 'https://{s}.basemaps.cartocdn.com/rastertiles/light_nolabels/{z}/{x}/{y}.png', attribution: CartoAttribution, - name:'Positron Without Labels', + name:'Carto Positron Without Labels', minLevel: 0, maxLevel: 18 }, @@ -221,14 +221,14 @@ osmLayer.tileSources = { 'voyager-with-labels': { url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}.png', attribution: CartoAttribution, - name:'Voyager With Labels', + name:'Carto Voyager With Labels', minLevel: 0, maxLevel: 18 }, 'voyager-without-layers': { url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager_nolabels/{z}/{x}/{y}.png', attribution: CartoAttribution, - name:'Voyager Without Layers', + name:'Carto Voyager Without Layers', minLevel: 0, maxLevel: 18 },