//= require graphs/horizontal_bar_graph if (document.getElementById("cropmap") !== null) { mapbox_map_id = "<%= Rails.env == 'test' ? 0 : Rails.application.config.mapbox_map_id %>"; mapbox_access_token = "<%= Rails.env == 'test' ? 0 : Rails.application.config.mapbox_access_token %>"; mapbox_base_url = "http://a.tiles.mapbox.com/v4/" + mapbox_map_id + "/{z}/{x}/{y}.png?access_token=" + mapbox_access_token; L.Icon.Default.imagePath = '/assets' cropmap = L.map('cropmap').setView([0.0, -0.0], 2); showCropMap(cropmap); } function showCropMap(cropmap) { L.tileLayer(mapbox_base_url, { attribution: 'Map data © OpenStreetMap contributors under ODbL | Map imagery © Mapbox', maxZoom: 18 }).addTo(cropmap); markers = new L.MarkerClusterGroup({showCoverageOnHover: false, maxClusterRadius: 20 }); things_to_map = location.pathname + '.json'; $.getJSON(things_to_map, function(crop) { $.each(crop.plantings, function(i, planting) { owner = planting.owner; if (owner.latitude && owner.longitude) { marker = new L.Marker(new L.LatLng(owner.latitude, owner.longitude)); planting_url = "/plantings/" + planting.id; planting_link = "" + owner.login_name + "'s " + crop.name + ""; where = "
" + owner.location + "
"; details = "";
if (planting.quantity) {
details = details + "Quantity: " + planting.quantity + "
";
}
if (planting.planted_from) {
details = details + "Planted from: " + planting.planted_from + "
";
}
if (planting.sunniness) {
details = details + "Planted in: " + planting.sunniness+ "
";
}
details = details + "