mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-29 10:18:29 -04:00
- Implemented `planting_alternate_name.js` to load alternate names for crops in the planting form based on user input. - Added `tab_navigation.js` to manage tab navigation and update the URL hash accordingly. Update map rendering in member and place views - Modified `_map.html.haml` to include a custom marker icon for member maps. - Updated `index.html.haml` and `show.html.haml` to pass `places_map_data` to the map sections. Refactor asset management in Rails application - Removed Sprockets from the application configuration and adjusted asset paths. - Updated asset precompilation settings and removed deprecated asset configurations from environment files. - Added new build scripts for CSS and updated package dependencies in `package.json` for Bootstrap, Chart.js, and others. Ensure React and CSS bundles are built before running tests - Updated `react_bundle.rb` to check for the existence of both JavaScript and CSS bundles and build them if missing.
59 lines
1.9 KiB
JavaScript
59 lines
1.9 KiB
JavaScript
function showCropMap(cropmap) {
|
|
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
|
maxZoom: 18
|
|
}).addTo(cropmap);
|
|
var markers = new L.MarkerClusterGroup({showCoverageOnHover: false, maxClusterRadius: 20 });
|
|
|
|
var crop_icon = L.icon({
|
|
iconUrl: location.pathname + '.svg',
|
|
iconSize: [24, 24],
|
|
iconAnchor: [12, 12],
|
|
popupAnchor: [0, -12],
|
|
});
|
|
|
|
var things_to_map = location.pathname + '.json';
|
|
$.getJSON(things_to_map, function(crop) {
|
|
$.each(crop.plantings, function(i, planting) {
|
|
var owner = planting.owner;
|
|
if (owner.latitude && owner.longitude) {
|
|
var marker = new L.Marker(new L.LatLng(owner.latitude, owner.longitude),
|
|
{'icon': crop_icon});
|
|
|
|
var planting_url = "/plantings/" + planting.id;
|
|
var planting_link = "<a href='" + planting_url + "'>" + owner.login_name + "'s " + crop.name + "</a>";
|
|
|
|
var where = "<p><i>" + owner.location + "</i></p>";
|
|
|
|
var details = "<p>";
|
|
if (planting.quantity) {
|
|
details = details + "Quantity: " + planting.quantity + "<br/>";
|
|
}
|
|
if (planting.planted_from) {
|
|
details = details + "Planted from: " + planting.planted_from + "<br/>";
|
|
}
|
|
if (planting.sunniness) {
|
|
details = details + "Planted in: " + planting.sunniness+ "<br/>";
|
|
}
|
|
details = details + "</p>";
|
|
marker.bindPopup(planting_link + where + details).openPopup();
|
|
markers.addLayer(marker);
|
|
}
|
|
});
|
|
});
|
|
|
|
cropmap.addLayer(markers);
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
|
|
if (document.getElementById("cropmap") !== null) {
|
|
var cropmap = L.map('cropmap').setView([0.0, -0.0], 2);
|
|
showCropMap(cropmap);
|
|
}
|
|
|
|
$('.btn.toggle.crop-hierarchy').click(function () {
|
|
$('.toggle.crop-hierarchy').toggleClass('hide');
|
|
});
|
|
});
|