Skip to content

Commit

Permalink
Rebased omt-vector-map onto upstream/master and resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
zdila committed Feb 4, 2025
1 parent d66d9f6 commit e683509
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
47 changes: 26 additions & 21 deletions app/assets/javascripts/leaflet.map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -104,6 +83,32 @@ L.OSM.Map = L.Map.extend({
this.baseLayers.push(layer);
}

if (L.OpenMapTiles) {
var copyright_link = $("<a>", {
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 = $("<a>", {
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" };

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e683509

Please sign in to comment.