diff --git a/app/assets/javascripts/embed.js.erb b/app/assets/javascripts/embed.js.erb index 3d96a78d58..e2b6fb8de6 100644 --- a/app/assets/javascripts/embed.js.erb +++ b/app/assets/javascripts/embed.js.erb @@ -37,20 +37,6 @@ window.onload = function () { map.attributionControl.setPrefix(''); map.removeControl(map.attributionControl); - if (!args.layer || args.layer === "mapnik" || args.layer === "osmarender" || args.layer === "mapquest") { - new L.OSM.Mapnik().addTo(map); - } else if (args.layer === "historical") { - new L.OSM.Historical().addTo(map); - } else if (args.layer === "cyclemap" || args.layer === "cycle map") { - new L.OSM.CycleMap(thunderforestOptions).addTo(map); - } else if (args.layer === "transportmap") { - new L.OSM.TransportMap(thunderforestOptions).addTo(map); - } else if (args.layer === "hot") { - new L.OSM.HOT().addTo(map); - } else { - new L.OSM.Mapnik(mapnikOptions).addTo(map); - } - if (args.marker) { L.marker(args.marker.split(','), {icon: L.icon({ iconUrl: <%= asset_path('leaflet/dist/images/marker-icon.png').to_json %>, diff --git a/app/assets/javascripts/leaflet.map.js b/app/assets/javascripts/leaflet.map.js index 51ab83d1e7..cd932c3da7 100644 --- a/app/assets/javascripts/leaflet.map.js +++ b/app/assets/javascripts/leaflet.map.js @@ -44,13 +44,6 @@ L.OSM.Map = L.Map.extend({ }).prop("outerHTML"); var cyclosm = I18n.t("javascripts.map.cyclosm_credit", { cyclosm_link: cyclosm_link, osm_france_link: osm_france_link }); - var thunderforest_link = $("", { - href: "https://www.thunderforest.com/", - target: "_blank", - text: I18n.t("javascripts.map.andy_allan") - }).prop("outerHTML"); - var thunderforest = I18n.t("javascripts.map.thunderforest_credit", { thunderforest_link: thunderforest_link }); - var memomaps_link = $("", { href: "https://memomaps.de/", target: "_blank", @@ -144,48 +137,88 @@ L.OSM.Map = L.Map.extend({ name: I18n.t("javascripts.map.base.standard") })); - this.baseLayers.push(new L.OSM.CyclOSM({ + this.baseLayers.push(new L.MaplibreGL({ attribution: copyright + ". " + cyclosm + ". " + terms, code: "Y", - keyid: "cyclosm", - name: I18n.t("javascripts.map.base.cyclosm") + keyid: "cyclosm", + name: I18n.t("javascripts.map.base.cyclosm"), + style: { + version: 8, + sources: { + 'cyclosm': { + type: 'raster', + tiles: [ + 'https://a.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png', + 'https://b.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png', + 'https://c.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png' + ], + tileSize: 256, + attribution: `${copyright}. ${cyclosm}. ${terms}`, + maxzoom: 20 + } + }, + layers: [{ + id: 'cyclosm', + type: 'raster', + source: 'cyclosm' + }] + } })); - if (OSM.THUNDERFOREST_KEY) { - this.baseLayers.push(new L.OSM.CycleMap({ - attribution: copyright + ". " + thunderforest + ". " + terms, - apikey: OSM.THUNDERFOREST_KEY, - code: "C", - keyid: "cyclemap", - name: I18n.t("javascripts.map.base.cycle_map") - })); - - this.baseLayers.push(new L.OSM.TransportMap({ - attribution: copyright + ". " + thunderforest + ". " + terms, - apikey: OSM.THUNDERFOREST_KEY, - code: "T", - keyid: "transportmap", - name: I18n.t("javascripts.map.base.transport_map") - })); - } - - this.baseLayers.push(new L.OSM.HOT({ + this.baseLayers.push(new L.MaplibreGL({ attribution: copyright + ". " + hotosm + ". " + terms, - code: "H", + code: "H", keyid: "hot", - name: I18n.t("javascripts.map.base.hot") + name: I18n.t("javascripts.map.base.hot"), + style: { + version: 8, + sources: { + 'hot': { + type: 'raster', + tiles: [ + 'https://tile-a.openstreetmap.fr/hot/{z}/{x}/{y}.png', + 'https://tile-b.openstreetmap.fr/hot/{z}/{x}/{y}.png', + 'https://tile-c.openstreetmap.fr/hot/{z}/{x}/{y}.png' + ], + tileSize: 256, + maxzoom: 20 + } + }, + layers: [{ + id: 'hot', + type: 'raster', + source: 'hot' + }] + } })); - this.noteLayer = new L.FeatureGroup(); this.noteLayer.options = { code: "N" }; this.dataLayer = new L.OSM.DataLayer(null); this.dataLayer.options.code = "D"; - this.gpsLayer = new L.OSM.GPS({ - pane: "overlayPane", + this.gpsLayer = new L.MaplibreGL({ code: "G", - name: I18n.t("javascripts.map.base.gps") + name: I18n.t("javascripts.map.base.gps"), + style: { + version: 8, + sources: { + 'gps': { + type: 'raster', + tiles: [ + 'https://gps.tile.openstreetmap.org/lines/{z}/{x}/{y}.png' + ], + tileSize: 256, + maxZoom: 21, + maxNativeZoom: 20 + } + }, + layers: [{ + id: 'gps', + type: 'raster', + source: 'gps' + }] + } }); this.on("layeradd", function (event) { diff --git a/app/assets/javascripts/leaflet.share.js b/app/assets/javascripts/leaflet.share.js index 121ed4e79e..06574366d0 100644 --- a/app/assets/javascripts/leaflet.share.js +++ b/app/assets/javascripts/leaflet.share.js @@ -337,7 +337,6 @@ L.OSM.share = function (options) { } function update() { - var canEmbed = map.getMapBaseLayerId() !== "tracestracktopo"; var bounds = map.getBounds(); $("#link_marker") @@ -364,13 +363,10 @@ L.OSM.share = function (options) { } $("#embed_link") - .toggleClass("btn-primary", canEmbed) - .toggleClass("btn-secondary", !canEmbed) - .tooltip(canEmbed ? "disable" : "enable"); - if (!canEmbed && $("#embed_link").hasClass("active")) { - $("#long_link").click(); - } - + .toggleClass("btn-primary", true) + .toggleClass("btn-secondary", false) + .tooltip("disable"); + const parsedHash = new URLSearchParams(location.hash), embeddedMapPath = parsedHash.get('#map'), diff --git a/app/assets/javascripts/osm.js.erb b/app/assets/javascripts/osm.js.erb index f66c138f4a..4f3381f3b8 100644 --- a/app/assets/javascripts/osm.js.erb +++ b/app/assets/javascripts/osm.js.erb @@ -27,10 +27,6 @@ OSM = { THUNDERFOREST_KEY: <%= Settings.thunderforest_key.to_json %>, <% end %> -<% if Settings.key?(:tracestrack_key) %> - TRACESTRACK_KEY: <%= Settings.tracestrack_key.to_json %>, -<% end %> - LAYERS_WITH_MAP_KEY: <%= YAML.load_file(Rails.root.join("config/key.yml")).keys.to_json %>, MARKER_GREEN: <%= image_path("marker-green.png").to_json %>, diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index ad3d0907e3..4f558c58f9 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -6,7 +6,7 @@ Rails.application.configure do connect_src = [:self, "*.openhistoricalmap.org", "openhistoricalmap.github.io", "*.amazonaws.com"] - img_src = [:self, :data, "www.gravatar.com", "*.wp.com", "tile.openstreetmap.org", "gps.tile.openstreetmap.org", "*.tile.thunderforest.com", "tile.tracestrack.com", "*.openstreetmap.fr"] + img_src = [:self, :data, "www.gravatar.com", "*.wp.com", "tile.openstreetmap.org", "gps.tile.openstreetmap.org", "*.tile.thunderforest.com", "*.openstreetmap.fr"] script_src = [:self, "openhistoricalmap.github.io"] style_src = [:self, "openhistoricalmap.github.io"] worker_src = [:self, :blob, "0.0.0.0:3000"] diff --git a/config/settings.yml b/config/settings.yml index bd5b4c1d27..4b5cbc6087 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -147,8 +147,6 @@ fossgis_valhalla_url: "https://valhalla1.openstreetmap.de/route" # Thunderforest authentication details #thunderforest_key: "" -# Tracestrack authentication details -#tracestrack_key: "" # Key for generating TOTP tokens #totp_key: "" # Enforce Content-Security-Policy diff --git a/vendor/assets/leaflet/leaflet.osm.js b/vendor/assets/leaflet/leaflet.osm.js index 56ffd368ad..1d4d60ab60 100644 --- a/vendor/assets/leaflet/leaflet.osm.js +++ b/vendor/assets/leaflet/leaflet.osm.js @@ -19,72 +19,6 @@ L.OSM.Mapnik = L.OSM.TileLayer.extend({ } }); -L.OSM.CyclOSM = L.OSM.TileLayer.extend({ - options: { - url: 'https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png', - maxZoom: 20, - subdomains: 'abc', - attribution: '© OpenStreetMap contributors. Tiles courtesy of OpenStreetMap France' - } -}); - -L.OSM.Historical = L.OSM.TileLayer.extend({ - options: { - url: 'http://www.openhistoricalmap.org/ohm_tiles/{z}/{x}/{y}.png', - maxZoom: 20 - } -}); - -L.OSM.CycleMap = L.OSM.TileLayer.extend({ - options: { - url: 'https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}{r}.png?apikey={apikey}', - maxZoom: 21, - attribution: '© OpenStreetMap contributors. Tiles courtesy of Andy Allan' - } -}); - -L.OSM.TransportMap = L.OSM.TileLayer.extend({ - options: { - url: 'https://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}{r}.png?apikey={apikey}', - maxZoom: 21, - attribution: '© OpenStreetMap contributors. Tiles courtesy of Andy Allan' - } -}); - -L.OSM.OPNVKarte = L.OSM.TileLayer.extend({ - options: { - url: 'https://tileserver.memomaps.de/tilegen/{z}/{x}/{y}.png', - maxZoom: 18, - attribution: '© OpenStreetMap contributors. Tiles courtesy of MeMoMaps' - } -}); - -L.OSM.HOT = L.OSM.TileLayer.extend({ - options: { - url: 'https://tile-{s}.openstreetmap.fr/hot/{z}/{x}/{y}.png', - maxZoom: 20, - subdomains: 'abc', - attribution: '© OpenStreetMap contributors. Tiles courtesy of Humanitarian OpenStreetMap Team' - } -}); - -L.OSM.TracestrackTopo = L.OSM.TileLayer.extend({ - options: { - url: 'https://tile.tracestrack.com/topo__/{z}/{x}/{y}.png?key={apikey}', - maxZoom: 19, - attribution: '© OpenStreetMap contributors. Tiles courtesy of Tracestrack Maps' - } -}); - -L.OSM.GPS = L.OSM.TileLayer.extend({ - options: { - url: 'https://gps.tile.openstreetmap.org/lines/{z}/{x}/{y}.png', - maxZoom: 21, - maxNativeZoom: 20, - subdomains: 'abc' - } -}); - L.OSM.DataLayer = L.FeatureGroup.extend({ options: { areaTags: ['area', 'building', 'leisure', 'tourism', 'ruins', 'historic', 'landuse', 'military', 'natural', 'sport'],