Skip to content

Commit ea1591b

Browse files
committed
add protomaps
1 parent d597c28 commit ea1591b

5 files changed

Lines changed: 15 additions & 5 deletions

File tree

23 KB
Loading
File renamed without changes.

app/javascript/maplibre/styles/basemaps.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export function basemaps () {
168168
}
169169
},
170170
// https://manage.thunderforest.com/dashboard
171-
openCycleMap: {
171+
thunderforestCycle: {
172172
description: window.__('Thunderforest Cycle map with elevation contours and cycling infrastructure.'),
173173
style: {
174174
version: 8,
@@ -216,6 +216,9 @@ export function basemaps () {
216216
openfreemapBright: { description: window.__('Bright, colorful vector style with clear roads and readable labels.'), style: 'https://tiles.openfreemap.org/styles/bright', defaults: { font: notoFont } },
217217
openfreemapLiberty: { description: window.__('Detailed vector map with landmarks, buildings and points of interest.'), style: 'https://tiles.openfreemap.org/styles/liberty', sourceName: 'openmaptiles', defaults: { font: notoFont } },
218218

219+
// https://protomaps.com/api, themes: light, dark, white, grayscale, black
220+
protomapsLight: { description: window.__('Light Protomaps vector style with soft colors and clear labels.'), style: 'https://api.protomaps.com/styles/v5/light/en.json?key=' + window.gon.map_keys.protomaps, sourceName: 'protomaps', defaults: { font: notoFont } },
221+
219222
// https://github.com/versatiles-org/versatiles-style
220223
// fonts: https://github.com/versatiles-org/versatiles-fonts
221224
versatilesColorful: { description: window.__('Colorful vector map with vivid colors and a clear road hierarchy.'), style: 'https://tiles.versatiles.org/assets/styles/colorful/style.json', sourceName: 'versatiles-shortbread' },

app/models/map.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,20 @@ class Map
5656

5757
# Only BASE_MAPS are available in the UI
5858
BASE_MAPS = [ "versatilesColorful", "satelliteStreets", "openTopoTiles",
59-
"openfreemapLiberty", "versatilesGraybeard", "versatilesEclipse",
60-
"stamenWatercolorTiles", "cyclosmTiles", "basemapWorld" ]
59+
"openfreemapLiberty", "protomapsLight", "versatilesGraybeard", "versatilesEclipse",
60+
"stamenWatercolorTiles", "cyclosmTiles", "basemapWorld", "artistic" ]
6161
# App admins can also select from these maps
62-
EXPERIMENTAL_MAPS = [ "stamenTonerTiles", "openCycleMap", "versatilesGraybeardSnow", "thunderforestContrast", "artistic", "versatilesSatelliteStreets" ]
62+
EXPERIMENTAL_MAPS = [ "stamenTonerTiles", "thunderforestCycle", "versatilesGraybeardSnow", "thunderforestContrast", "versatilesSatelliteStreets" ]
6363

6464
STADIA_MAPS = [ "stamenTonerTiles", "stamenWatercolorTiles" ]
6565
OPENFREE_MAPS = [ "openfreemapPositron", "openfreemapBright", "openfreemapLiberty" ]
6666
VERSATILES_MAPS = [ "versatilesColorful", "versatilesGraybeard", "versatilesGraybeardSnow", "artistic", "versatilesSatelliteStreets" ]
6767
MAPTILER_MAPS = [ "maptilerBuildings", "maptilerHybrid", "maptilerDataviz",
6868
"maptilerStreets", "maptilerNoStreets", "maptilerWinter",
6969
"maptilerBike", "maptilerBasic" ]
70+
PROTOMAPS_MAPS = [ "protomapsLight" ]
7071
OTHER_MAPS = [ "cyclosmTiles", "satelliteStreets", "osmRasterTiles",
71-
"openCycleMap", "thunderforestContrast" ]
72+
"thunderforestCycle", "thunderforestContrast" ]
7273

7374
DEFAULT_CENTER = [ 11.077, 49.447 ].freeze
7475
DEFAULT_ZOOM = 10
@@ -174,6 +175,7 @@ def self.provider_keys
174175
maptiler: ENV["MAPTILER_KEY"],
175176
openrouteservice: ENV["OPENROUTESERVICE_KEY"],
176177
thunderforest: ENV["THUNDERFOREST_KEY"],
178+
protomaps: ENV["PROTOMAPS_KEY"],
177179
indoorequal: ENV["INDOOREQUAL_KEY"] }
178180
end
179181

@@ -329,6 +331,10 @@ def get_base_map
329331
return base_map if ENV["MAPTILER_KEY"].present?
330332
logger.warn("Cannot use maptiler map #{base_map} without MAPTILER_KEY. Falling back to: #{default_base_map}")
331333
return default_base_map
334+
elsif PROTOMAPS_MAPS.include?(base_map)
335+
return base_map if ENV["PROTOMAPS_KEY"].present?
336+
logger.warn("Cannot use protomaps map #{base_map} without PROTOMAPS_KEY. Falling back to: #{default_base_map}")
337+
return default_base_map
332338
elsif (BASE_MAPS + OPENFREE_MAPS + VERSATILES_MAPS + STADIA_MAPS + OTHER_MAPS).include?(base_map) || base_map == "test"
333339
return base_map
334340
end

app/views/maps/modals/_settings.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
= _("Background map")
3737

3838
- maps = (@user&.admin? ? Map::BASE_MAPS + Map::EXPERIMENTAL_MAPS : Map::BASE_MAPS)
39+
- maps -= Map::PROTOMAPS_MAPS if ENV["PROTOMAPS_KEY"].blank?
3940
- maps.each do |base_map|
4041
- active = (@map_properties[:base_map] == base_map)
4142
- map_image = "base_maps/placeholder.jpg"

0 commit comments

Comments
 (0)