Skip to content

Commit

Permalink
perf: Add basemaps from Carto (#1107)
Browse files Browse the repository at this point in the history
* adds basemaps from Carto

* updates example and adds name to layer def.

* updates carto names in def

Co-authored-by: Mary Salvi <[email protected]>
  • Loading branch information
marySalvi and Mary Salvi authored Sep 28, 2021
1 parent ccf2a37 commit 657368c
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 9 deletions.
8 changes: 0 additions & 8 deletions examples/measure/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down
12 changes: 11 additions & 1 deletion examples/measure/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions src/osmLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ let StamenAttribution = 'Map tiles by <a href="http://stamen.com">Stamen ' +
'CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap' +
'</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.';

/* Per Carto's website regarding basemap attribution: https://carto.com/help/working-with-data/attribution/#basemaps */
let CartoAttribution = '<a href="https://carto.com"> Carto</a> ' + 'Contributors <a href="https://www.openstreetmap.org/"> OpenStreetMap</a>';

/**
* This is a list of known tile sources. It can be added to via
* `geo.osmLayer.tilesource[<key>] = <object>`, where the object has `url`,
Expand All @@ -139,51 +142,100 @@ let StamenAttribution = 'Map tiles by <a href="http://stamen.com">Stamen ' +
* @type {object}
*/
osmLayer.tileSources = {
'dark-matter-with-labels': {
url: ' https://{s}.basemaps.cartocdn.com/rastertiles/dark_all/{z}/{x}/{y}.png',
attribution: CartoAttribution,
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: 'Carto 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 <a href="https://basemap.nationalmap.gov/">USGS</a>',
name:'National Map Satellite',
minLevel: 0,
maxLevel: 16
},
osm: {
url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
attribution: 'Tile data &copy; <a href="https://osm.org/copyright">' +
'OpenStreetMap</a> contributors',
name:'OpenStreetMap',
subdomains: 'abc',
minLevel: 0,
maxLevel: 19
},
'positron-with-labels': {
url: 'https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png',
attribution: CartoAttribution,
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:'Carto 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
},
'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
},
'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
},
'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
},
'voyager-with-labels': {
url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}.png',
attribution: CartoAttribution,
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:'Carto Voyager Without Layers',
minLevel: 0,
maxLevel: 18
},
'wikimedia': {
url: 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png',
attribution: '<a href="https://wikimediafoundation.org/wiki/Maps_Terms_of_Use">Wikimedia maps</a> | Map data &copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap contributors</a>',
name:'Wikimedia',
minLevel: 0,
maxLevel: 19
}
Expand Down

0 comments on commit 657368c

Please sign in to comment.