1 function createMap(divName) {
3 var map = L.map(divName);
5 // Create a layer switcher
6 var layers = L.control.layers();
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>",
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 }), <%= layer[:name].to_json %>);
21 <% @overlays.each do |layer| -%>
22 // Add <%= layer[:name].to_json %> layer
23 layers.addOverlay(L.tileLayer(<%= layer[:url].to_json %>, {
24 attribution: <%= layer[:attribution].to_json %>
25 }), <%= layer[:name].to_json %>);
28 // Add the layer switch to the mao
31 // Zoom to specified bounds
32 map.fitBounds(<%= @bbox.to_json %>);