2023-06-15 14:09:04 +02:00
|
|
|
$(document).ready(function() {
|
2022-10-13 16:10:43 +02:00
|
|
|
if(!$('body').hasClass('sidebar-collapse')){
|
2024-05-21 17:43:38 +02:00
|
|
|
$('body').addClass('sidebar-collapse');
|
2022-10-13 16:10:43 +02:00
|
|
|
}
|
|
|
|
|
2023-06-15 14:09:04 +02:00
|
|
|
setTimeout(function () {
|
|
|
|
caricaMappa();
|
|
|
|
reload_pointers();
|
|
|
|
}, 1000);
|
2022-10-13 16:10:43 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
let map;
|
|
|
|
var markers = [];
|
|
|
|
|
2023-06-15 14:09:04 +02:00
|
|
|
$('#menu-filtri-toggle').click(function() {
|
2022-10-13 16:10:43 +02:00
|
|
|
|
|
|
|
if($(this).parent().parent().parent().hasClass("open-menu")){
|
|
|
|
$(this).parent().parent().parent().removeClass("open-menu");
|
|
|
|
$(this).parent().parent().parent().addClass("closed-menu");
|
|
|
|
|
|
|
|
$(this).removeClass('fa-forward');
|
|
|
|
$(this).addClass('fa-backward');
|
|
|
|
|
|
|
|
$('#lista-filtri').hide();
|
|
|
|
}else{
|
|
|
|
$(this).parent().parent().parent().removeClass("closed-menu");
|
|
|
|
$(this).parent().parent().parent().addClass("open-menu");
|
|
|
|
|
|
|
|
$(this).removeClass('fa-backward');
|
|
|
|
$(this).addClass('fa-forward');
|
|
|
|
|
|
|
|
$('#lista-filtri').show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-08-09 17:01:10 +02:00
|
|
|
|
2023-06-15 14:09:04 +02:00
|
|
|
function reload_pointers() {
|
2022-10-13 16:10:43 +02:00
|
|
|
clearMarkers();
|
|
|
|
var check = [];
|
2024-08-09 17:01:10 +02:00
|
|
|
var svgContent = "";
|
2022-10-13 16:10:43 +02:00
|
|
|
|
2023-06-15 14:09:04 +02:00
|
|
|
$("input[type='checkbox']").each(function() {
|
2022-10-13 16:10:43 +02:00
|
|
|
if($(this).is(':checked')){
|
|
|
|
id = $(this).attr('id');
|
|
|
|
|
|
|
|
check.push(id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-08-09 17:01:10 +02:00
|
|
|
$.ajax({
|
|
|
|
url: globals.rootdir + '/assets/dist/img/leaflet/place-marker.svg', // Percorso al file SVG
|
|
|
|
dataType: 'text', // Imposta il tipo di dati attesi
|
|
|
|
success: function(data) {
|
|
|
|
svgContent = data; // Inserisci il contenuto SVG nella variabile
|
|
|
|
},
|
|
|
|
error: function() {
|
|
|
|
alert('Failed to load SVG file.');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$.get(globals.rootdir + '/modules/mappa/actions.php?op=get_markers&idanagrafica='+$('#idanagrafica').val()+'&check='+check, function(data){
|
2022-10-13 16:10:43 +02:00
|
|
|
var dettagli = JSON.parse(data);
|
|
|
|
dettagli.forEach(function(dettaglio) {
|
|
|
|
|
2023-06-15 14:09:04 +02:00
|
|
|
if (dettaglio.lat && dettaglio.lng) {
|
2024-08-09 17:01:10 +02:00
|
|
|
let svgIcon = L.divIcon({
|
|
|
|
html: svgContent.replace('fill="#cccccc"','fill="' + dettaglio.colore + '"'),
|
|
|
|
className: '',
|
|
|
|
shadowUrl:globals.rootdir + "/assets/dist/img/leaflet/marker-shadow.png",
|
|
|
|
iconSize: [45, 61],
|
|
|
|
iconAnchor: [12, 41],
|
|
|
|
popupAnchor: [1, -34],
|
|
|
|
shadowSize: [41, 41]
|
|
|
|
});
|
|
|
|
|
2023-06-15 14:09:04 +02:00
|
|
|
L.marker([dettaglio.lat, dettaglio.lng], {
|
2024-08-09 17:01:10 +02:00
|
|
|
icon: svgIcon
|
|
|
|
}).bindTooltip("",
|
|
|
|
{
|
|
|
|
permanent: false,
|
|
|
|
direction: 'right'
|
|
|
|
}
|
|
|
|
).bindPopup(dettaglio.descrizione
|
|
|
|
).addTo(map);
|
2023-06-15 14:09:04 +02:00
|
|
|
}
|
2022-10-13 16:10:43 +02:00
|
|
|
});
|
2024-08-09 17:01:10 +02:00
|
|
|
|
|
|
|
if (input("lat").get() && input("lng").get()) {
|
|
|
|
const lat = parseFloat(input("lat").get());
|
|
|
|
const lng = parseFloat(input("lng").get());
|
|
|
|
|
|
|
|
var icon = new L.Icon({
|
|
|
|
iconUrl: globals.rootdir + "/assets/dist/img/marker-icon.png",
|
|
|
|
shadowUrl:globals.rootdir + "/assets/dist/img/leaflet/marker-shadow.png",
|
|
|
|
iconSize: [25, 41],
|
|
|
|
iconAnchor: [12, 41],
|
|
|
|
popupAnchor: [1, -34],
|
|
|
|
shadowSize: [41, 41]
|
|
|
|
});
|
|
|
|
|
|
|
|
L.marker([lat, lng], {
|
|
|
|
icon: icon
|
|
|
|
}).addTo(map);
|
|
|
|
}
|
2022-10-13 16:10:43 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearMarkers() {
|
2023-06-15 14:09:04 +02:00
|
|
|
map.eachLayer(function (layer) {
|
|
|
|
if(layer instanceof L.Marker) {
|
|
|
|
map.removeLayer(layer);
|
|
|
|
}
|
|
|
|
});
|
2022-10-13 16:10:43 +02:00
|
|
|
}
|
|
|
|
|
2023-06-15 14:09:04 +02:00
|
|
|
$("input[type='checkbox']").change(function() {
|
2022-10-13 16:10:43 +02:00
|
|
|
reload_pointers();
|
|
|
|
});
|
|
|
|
|
2023-06-15 14:09:04 +02:00
|
|
|
$('#idanagrafica').change(function() {
|
2022-10-13 16:10:43 +02:00
|
|
|
reload_pointers();
|
|
|
|
});
|
|
|
|
|