X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/f9209d75d16ec9731ac9f50313a6c0f42d4b955a..a0858dce1ce11c24de0103a341bc0ea8f75154ea:/cookbooks/imagery/templates/default/imagery.js.erb diff --git a/cookbooks/imagery/templates/default/imagery.js.erb b/cookbooks/imagery/templates/default/imagery.js.erb index 44e8bd218..d3ad65458 100644 --- a/cookbooks/imagery/templates/default/imagery.js.erb +++ b/cookbooks/imagery/templates/default/imagery.js.erb @@ -12,15 +12,22 @@ function createMap(divName) { }), "OpenStreetMap"); <% @layers.sort_by { |layer| layer[:name] }.each do |layer| -%> - // Add <%= layer[:name].to_json %> layer - layers.addBaseLayer(L.tileLayer(<%= layer[:url].to_json %>, { + // Create <%= layer[:name] %> layer + var <%= layer[:name] %> = L.tileLayer(<%= layer[:url].to_json %>, { attribution: <%= layer[:attribution].to_json %>, maxZoom: <%= layer[:maxZoom].to_json %> - }), <%= layer[:name].to_json %>); + }); + + // Add <%= layer[:name] %> to layer switcher + layers.addBaseLayer(<%= layer[:name] %>, <%= layer[:name].to_json %>); + <% if layer[:default] -%> + // Add <%= layer[:name] %> to map + <%= layer[:name] %>.addTo(map); + <% end -%> <% end -%> <% @overlays.sort_by { |layer| layer[:name] }.each do |layer| -%> - // Add <%= layer[:name].to_json %> layer + // Add <%= layer[:name] %> to layer switcher layers.addOverlay(L.tileLayer(<%= layer[:url].to_json %>, { attribution: <%= layer[:attribution].to_json %>, maxZoom: <%= layer[:maxZoom].to_json %>