]> git.openstreetmap.org Git - chef.git/blob - cookbooks/imagery/templates/default/imagery.js.erb
imagery: add additional gb_os_sv_diff layers
[chef.git] / cookbooks / imagery / templates / default / imagery.js.erb
1 function createMap(divName) {
2   // Create a map
3   var map = L.map(divName);
4
5   // Create a layer switcher
6   var layers = L.control.layers();
7
8   // Add OpenStreetMap layer
9   layers.addBaseLayer(L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
10     attribution: "© <a target=\"_parent\" href=\"http://www.openstreetmap.org\">OpenStreetMap</a> and contributors, under an <a target=\"_parent\" href=\"http://www.openstreetmap.org/copyright\">open license</a>",
11     maxZoom: 19
12   }), "OpenStreetMap");
13
14   <% @layers.each do |layer| -%>
15   // Add <%= layer[:name].to_json %> layer
16   layers.addBaseLayer(L.tileLayer(<%= layer[:url].to_json %>, {
17     attribution: <%= layer[:attribution].to_json %>,
18     maxZoom: <%= layer[:maxZoom].to_json %>
19   }), <%= layer[:name].to_json %>);
20
21   <% end -%>
22   <% @overlays.each do |layer| -%>
23   // Add <%= layer[:name].to_json %> layer
24   layers.addOverlay(L.tileLayer(<%= layer[:url].to_json %>, {
25     attribution: <%= layer[:attribution].to_json %>,
26     maxZoom: <%= layer[:maxZoom].to_json %>
27   }), <%= layer[:name].to_json %>);
28
29   <% end -%>
30   // Add the layer switch to the mao
31   layers.addTo(map);
32
33   // Zoom to specified bounds
34   map.fitBounds(<%= @bbox.to_json %>);
35
36   return map;
37 }