From 3c23952fd62d53c762cb2bbce9af96a2c413084c Mon Sep 17 00:00:00 2001 From: Cillian O'Ruanaidh Date: Fri, 31 Jul 2020 20:08:09 +0100 Subject: [PATCH 1/2] Don't double escape :open_street_map_provider_options so they are parsed into a JS object rather than a string. Before if you entered '{ accessToken: secret }' into the open street map provider options field in the admin content settings the 'JSON.parse(openStreetMapConfig.open_street_map_provider_options)' call in the open_street_map directive was converting them into a string because they were double escaped. They need to be converted into a JS object in order to set the Leaflet provider options. --- app/serializers/api/open_street_map_config_serializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/serializers/api/open_street_map_config_serializer.rb b/app/serializers/api/open_street_map_config_serializer.rb index 8c5aec5dbb..2253f3e15d 100644 --- a/app/serializers/api/open_street_map_config_serializer.rb +++ b/app/serializers/api/open_street_map_config_serializer.rb @@ -15,7 +15,7 @@ module Api end def open_street_map_provider_options - ContentConfig.open_street_map_provider_options.to_json + ContentConfig.open_street_map_provider_options end end end From ef7c7a3e7348a8afd351708a4c4797ddd422b3bf Mon Sep 17 00:00:00 2001 From: Cillian O'Ruanaidh Date: Fri, 31 Jul 2020 20:18:15 +0100 Subject: [PATCH 2/2] Upgrade vendored :leaflet-providers JS to 1.10.2 to update available OSM tile providers and fix deprecated MapBox endpoint. Before MapBox could no longer be used as an OSM tile provider as they recently deprecated their tile API endpoint (https://blog.mapbox.com/deprecating-studio-classic-styles-d8892ac38cb4) This update of leaflet-providers from 1.9.1 to 1.10.2 uses the new MapBox endpoint, it also adds new tile providers and removes some ones no longer supported. See https://github.com/leaflet-extras/leaflet-providers/blob/master/CHANGELOG.md#1102-2020-07-31 --- .../assets/javascripts/leaflet-providers.js | 123 +++++++++--------- 1 file changed, 64 insertions(+), 59 deletions(-) diff --git a/vendor/assets/javascripts/leaflet-providers.js b/vendor/assets/javascripts/leaflet-providers.js index 208b6257d0..6d8349839b 100644 --- a/vendor/assets/javascripts/leaflet-providers.js +++ b/vendor/assets/javascripts/leaflet-providers.js @@ -219,66 +219,16 @@ } }, CyclOSM: { - url: 'https://dev.{s}.tile.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png', + url: 'https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png', options: { maxZoom: 20, attribution: 'CyclOSM | Map data: {attribution.OpenStreetMap}' } }, - OpenMapSurfer: { - url: 'https://maps.heigit.org/openmapsurfer/tiles/{variant}/webmercator/{z}/{x}/{y}.png', - options: { - maxZoom: 19, - variant: 'roads', - attribution: 'Imagery from GIScience Research Group @ University of Heidelberg | Map data ' - }, - variants: { - Roads: { - options: { - variant: 'roads', - attribution: '{attribution.OpenMapSurfer}{attribution.OpenStreetMap}' - } - }, - Hybrid: { - options: { - variant: 'hybrid', - attribution: '{attribution.OpenMapSurfer}{attribution.OpenStreetMap}' - } - }, - AdminBounds: { - options: { - variant: 'adminb', - maxZoom: 18, - attribution: '{attribution.OpenMapSurfer}{attribution.OpenStreetMap}' - } - }, - ContourLines: { - options: { - variant: 'asterc', - maxZoom: 18, - minZoom: 13, - attribution: '{attribution.OpenMapSurfer} ASTER GDEM' - } - }, - Hillshade: { - options: { - variant: 'asterh', - maxZoom: 18, - attribution: '{attribution.OpenMapSurfer} ASTER GDEM, SRTM' - } - }, - ElementsAtRisk: { - options: { - variant: 'elements_at_risk', - attribution: '{attribution.OpenMapSurfer}{attribution.OpenStreetMap}' - } - } - } - }, Hydda: { url: 'https://{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png', options: { - maxZoom: 18, + maxZoom: 20, variant: 'full', attribution: 'Tiles courtesy of OpenStreetMap Sweden — Map data {attribution.OpenStreetMap}' }, @@ -288,18 +238,73 @@ RoadsAndLabels: 'roads_and_labels' } }, - MapBox: { - url: 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}{r}.png?access_token={accessToken}', + Jawg: { + url: 'https://{s}.tile.jawg.io/{variant}/{z}/{x}/{y}{r}.png?access-token={accessToken}', options: { attribution: - '© Mapbox ' + + '© JawgMaps ' + + '{attribution.OpenStreetMap}', + minZoom: 0, + maxZoom: 22, + subdomains: 'abcd', + variant: 'jawg-terrain', + // Get your own Jawg access token here : https://www.jawg.io/lab/ + // NB : this is a demonstration key that comes with no guarantee + accessToken: '', + }, + variants: { + Streets: 'jawg-streets', + Terrain: 'jawg-terrain', + Sunny: 'jawg-sunny', + Dark: 'jawg-dark', + Light: 'jawg-light', + Matrix: 'jawg-matrix' + } + }, + MapBox: { + url: 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}{r}?access_token={accessToken}', + options: { + attribution: + '© Mapbox ' + '{attribution.OpenStreetMap} ' + 'Improve this map', - subdomains: 'abcd', - id: 'mapbox.streets', + tileSize: 512, + maxZoom: 18, + zoomOffset: -1, + id: 'mapbox/streets-v11', accessToken: '', } }, + MapTiler: { + url: 'https://api.maptiler.com/maps/{variant}/{z}/{x}/{y}{r}.{ext}?key={key}', + options: { + attribution: + '© MapTiler © OpenStreetMap contributors', + variant: 'streets', + ext: 'png', + key: '', + tileSize: 512, + zoomOffset: -1, + minZoom: 0, + maxZoom: 21 + }, + variants: { + Streets: 'streets', + Basic: 'basic', + Bright: 'bright', + Pastel: 'pastel', + Positron: 'positron', + Hybrid: { + options: { + variant: 'hybrid', + ext: 'jpg' + } + }, + Toner: 'toner', + Topo: 'topo', + Voyager: 'voyager' + } + }, Stamen: { url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}{r}.{ext}', options: { @@ -719,11 +724,11 @@ } }, FreeMapSK: { - url: 'http://t{s}.freemap.sk/T/{z}/{x}/{y}.jpeg', + url: 'https://{s}.freemap.sk/T/{z}/{x}/{y}.jpeg', options: { minZoom: 8, maxZoom: 16, - subdomains: '1234', + subdomains: 'abcd', bounds: [[47.204642, 15.996093], [49.830896, 22.576904]], attribution: '{attribution.OpenStreetMap}, vizualization CC-By-SA 2.0 Freemap.sk'