]> git.openstreetmap.org Git - rails.git/commitdiff
Use an API key for thunderforest tile layers
authorTom Hughes <tom@compton.nu>
Thu, 8 Sep 2016 15:16:45 +0000 (16:16 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 8 Sep 2016 15:16:45 +0000 (16:16 +0100)
app/assets/javascripts/leaflet.map.js
app/assets/javascripts/osm.js.erb
vendor/assets/leaflet/leaflet.osm.js

index 7395898b7d488066e44a23b4d7766fd5fbda4205..19b030c29ea8a2a73dbe83a0a41a3e0147b1959c 100644 (file)
@@ -25,12 +25,14 @@ L.OSM.Map = L.Map.extend({
       }),
       new L.OSM.CycleMap({
         attribution: copyright + ". Tiles courtesy of <a href='http://www.thunderforest.com/' target='_blank'>Andy Allan</a>",
+        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 <a href='http://www.thunderforest.com/' target='_blank'>Andy Allan</a>",
+        apikey: OSM.THUNDERFOREST_KEY,
         code: "T",
         keyid: "transportmap",
         name: I18n.t("javascripts.map.base.transport_map")
index 138416be12525fa1fb1480c3e5151f69ffb76daa..10b7cfdb81cda46676c9d397ded0d558fcf61af6 100644 (file)
@@ -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 %>,
index 6b78fe9bea76dc9ef66951f77b24c5af1c4266ac..c6de9f749428591d7fe2fcc12965926102b0c5f4 100644 (file)
@@ -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: '© <a href="http://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors. Tiles courtesy of <a href="http://www.thunderforest.com/" target="_blank">Andy Allan</a>'
   }
 });
@@ -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: '© <a href="http://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors. Tiles courtesy of <a href="http://www.thunderforest.com/" target="_blank">Andy Allan</a>'
   }
 });