diff --git a/app/assets/javascripts/leaflet.map.js b/app/assets/javascripts/leaflet.map.js
index b43b23fed1..f5baa7a6ba 100644
--- a/app/assets/javascripts/leaflet.map.js
+++ b/app/assets/javascripts/leaflet.map.js
@@ -52,11 +52,6 @@ L.OSM.Map = L.Map.extend({
initialize: function (id, options) {
L.Map.prototype.initialize.call(this, id, options);
- var openmaptiles_link = I18n.t("javascripts.map.openmaptiles", {
- openmaptiles_url: "https://openmaptiles.org/",
- maptiler_url: "https://www.maptiler.com/"
- });
-
this.baseLayers = [];
for (const layerDefinition of OSM.LAYER_DEFINITIONS) {
@@ -65,22 +60,6 @@ L.OSM.Map = L.Map.extend({
let layerConstructor = L.OSM.TileLayer;
const layerOptions = {};
- if (L.OpenMapTiles) {
- this.baseLayers.push(new L.OpenMapTiles({
- attribution: copyright + ". " + openmaptiles_link + ". " + terms,
- code: "V",
- keyid: "openmaptiles_osm",
- name: I18n.t("javascripts.map.base.openmaptiles_osm")
- }));
- }
-
- this.baseLayers.push(new L.OpenMapTiles({
- attribution: copyright + ". " + openmaptiles_link + ". " + terms,
- code: "V",
- keyid: "openmaptiles_osm",
- name: I18n.t("javascripts.map.base.openmaptiles_osm")
- }));
-
for (const [property, value] of Object.entries(layerDefinition)) {
if (property === "credit") {
layerOptions.attribution = makeAttribution(value);
@@ -104,6 +83,32 @@ L.OSM.Map = L.Map.extend({
this.baseLayers.push(layer);
}
+ if (L.OpenMapTiles) {
+ var copyright_link = $("", {
+ href: "/copyright",
+ text: I18n.t("javascripts.map.openstreetmap_contributors")
+ }).prop("outerHTML");
+
+ var copyright = I18n.t("javascripts.map.copyright_text", { copyright_link: copyright_link });
+
+ var openmaptiles_link = I18n.t("javascripts.map.openmaptiles", {
+ openmaptiles_url: "https://openmaptiles.org/",
+ maptiler_url: "https://www.maptiler.com/"
+ });
+
+ var terms = $("", {
+ href: "https://wiki.osmfoundation.org/wiki/Terms_of_Use",
+ text: I18n.t("javascripts.map.website_and_api_terms")
+ }).prop("outerHTML");
+
+ this.baseLayers.push(new L.OpenMapTiles({
+ attribution: copyright + ". " + openmaptiles_link + ". " + terms,
+ code: "V",
+ keyid: "openmaptiles_osm",
+ name: I18n.t("javascripts.map.base.openmaptiles_osm")
+ }));
+ }
+
this.noteLayer = new L.FeatureGroup();
this.noteLayer.options = { code: "N" };
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 176fd8c2e0..d244ff8c7c 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -253,7 +253,7 @@ def fetch_body
def map_layout
policy = request.content_security_policy.clone
- policy.connect_src(*policy.connect_src, "http://127.0.0.1:8111", Settings.nominatim_url, Settings.overpass_url, Settings.fossgis_osrm_url, Settings.graphhopper_url, Settings.fossgis_valhalla_url)
+ policy.connect_src(*policy.connect_src, "http://127.0.0.1:8111", Settings.maptiler_url, Settings.nominatim_url, Settings.overpass_url, Settings.fossgis_osrm_url, Settings.graphhopper_url, Settings.fossgis_valhalla_url)
policy.form_action(*policy.form_action, "render.openstreetmap.org")
policy.style_src(*policy.style_src, :unsafe_inline)
diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb
index 9ddaf70f94..2b28b8c908 100644
--- a/config/initializers/content_security_policy.rb
+++ b/config/initializers/content_security_policy.rb
@@ -31,7 +31,7 @@
policy.plugin_types
policy.script_src(*script_src)
policy.style_src(:self)
- policy.worker_src(:none)
+ policy.worker_src(:blob)
policy.manifest_src(:self)
policy.report_uri(Settings.csp_report_url) if Settings.key?(:csp_report_url)
end
diff --git a/config/settings.yml b/config/settings.yml
index c791991451..89a1941d9f 100644
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -107,6 +107,8 @@ attachments_dir: ":rails_root/public/attachments"
#logstash_path: ""
# List of memcache servers to use for caching
#memcache_servers: []
+# URL of Maptiler API for vector maps
+maptiler_url: "https://api.maptiler.com/"
# URL of Nominatim instance to use for geocoding
nominatim_url: "https://nominatim.openstreetmap.org/"
# Default editor