From 3eda7be919f5b3bd88b5cf85ba1a3c1f72550d6f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 8 Sep 2016 16:16:45 +0100 Subject: [PATCH] Use an API key for thunderforest tile layers --- app/assets/javascripts/leaflet.map.js | 2 ++ app/assets/javascripts/osm.js.erb | 3 +++ vendor/assets/leaflet/leaflet.osm.js | 8 ++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/leaflet.map.js b/app/assets/javascripts/leaflet.map.js index 7395898b7..19b030c29 100644 --- a/app/assets/javascripts/leaflet.map.js +++ b/app/assets/javascripts/leaflet.map.js @@ -25,12 +25,14 @@ L.OSM.Map = L.Map.extend({ }), new L.OSM.CycleMap({ attribution: copyright + ". Tiles courtesy of Andy Allan", + apikey: OSM.THUNDERFOREST_KEY, code: "C", keyid: "cyclemap", name: I18n.t("javascripts.map.base.cycle_map") }), new L.OSM.TransportMap({ attribution: copyright + ". Tiles courtesy of Andy Allan", + apikey: OSM.THUNDERFOREST_KEY, code: "T", keyid: "transportmap", name: I18n.t("javascripts.map.base.transport_map") diff --git a/app/assets/javascripts/osm.js.erb b/app/assets/javascripts/osm.js.erb index 138416be1..10b7cfdb8 100644 --- a/app/assets/javascripts/osm.js.erb +++ b/app/assets/javascripts/osm.js.erb @@ -23,6 +23,9 @@ OSM = { <% if defined?(MAPZEN_VALHALLA_KEY) %> MAPZEN_VALHALLA_KEY: <%= MAPZEN_VALHALLA_KEY.to_json %>, <% end %> +<% if defined?(THUNDERFOREST_KEY) %> + THUNDERFOREST_KEY: <%= THUNDERFOREST_KEY.to_json %>, +<% end %> MARKER_GREEN: <%= image_path("marker-green.png").to_json %>, MARKER_RED: <%= image_path("marker-red.png").to_json %>, diff --git a/vendor/assets/leaflet/leaflet.osm.js b/vendor/assets/leaflet/leaflet.osm.js index 6b78fe9be..c6de9f749 100644 --- a/vendor/assets/leaflet/leaflet.osm.js +++ b/vendor/assets/leaflet/leaflet.osm.js @@ -26,8 +26,8 @@ L.OSM.Mapnik = L.OSM.TileLayer.extend({ L.OSM.CycleMap = L.OSM.TileLayer.extend({ options: { url: document.location.protocol === 'https:' ? - 'https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png' : - 'http://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png', + 'https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey={apikey}' : + 'http://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey={apikey}', attribution: '© OpenStreetMap contributors. Tiles courtesy of Andy Allan' } }); @@ -35,8 +35,8 @@ L.OSM.CycleMap = L.OSM.TileLayer.extend({ L.OSM.TransportMap = L.OSM.TileLayer.extend({ options: { url: document.location.protocol === 'https:' ? - 'https://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png' : - 'http://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png', + 'https://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey={apikey}' : + 'http://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey={apikey}', attribution: '© OpenStreetMap contributors. Tiles courtesy of Andy Allan' } }); -- 2.39.5