From: Anton Khorev Date: Fri, 24 Nov 2023 13:38:38 +0000 (+0300) Subject: Read layers with available map key from config/key.yml X-Git-Tag: live~972^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/857e9179b870203f1411bb6f9599ab676b77d5cf?hp=--cc Read layers with available map key from config/key.yml --- 857e9179b870203f1411bb6f9599ab676b77d5cf diff --git a/app/assets/javascripts/leaflet.key.js b/app/assets/javascripts/leaflet.key.js index 6a3400d34..bcd5839cd 100644 --- a/app/assets/javascripts/leaflet.key.js +++ b/app/assets/javascripts/leaflet.key.js @@ -24,7 +24,7 @@ L.OSM.key = function (options) { } function updateButton() { - var disabled = ["mapnik", "cyclemap"].indexOf(map.getMapBaseLayerId()) === -1; + var disabled = OSM.LAYERS_WITH_MAP_KEY.indexOf(map.getMapBaseLayerId()) === -1; button .toggleClass("disabled", disabled) .attr("data-bs-original-title", diff --git a/app/assets/javascripts/osm.js.erb b/app/assets/javascripts/osm.js.erb index 0a0f5c67a..2e33438db 100644 --- a/app/assets/javascripts/osm.js.erb +++ b/app/assets/javascripts/osm.js.erb @@ -1,5 +1,6 @@ //= depend_on settings.yml //= depend_on settings.local.yml +//= depend_on key.yml //= require qs/dist/qs OSM = { @@ -29,6 +30,8 @@ OSM = { 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 %>, MARKER_RED: <%= image_path("marker-red.png").to_json %>,