diff --git a/modules/anagrafiche/edit.php b/modules/anagrafiche/edit.php index 6afe77e07..62d3636e7 100755 --- a/modules/anagrafiche/edit.php +++ b/modules/anagrafiche/edit.php @@ -253,20 +253,22 @@ echo '
'; -$map_load_message = tr('Clicca per visualizzare'); - if (!empty($sede_cliente->gaddress) || (!empty($sede_cliente->lat) && !empty($sede_cliente->lng))) { echo ' -
-

'.$map_load_message.'

-
+

'; + // Navigazione diretta verso l'indirizzo + echo ' + + '.tr('Carica mappa').' + '; + // Modifica manuale delle informazioni echo ' - + '.tr('Aggiorna posizione').' '; }else{ @@ -341,21 +343,29 @@ echo ' return [lat, lng, indirizzo_default]; } + var map = null; function caricaMappa() { - const map_div = $("#map-edit"); - if (map_div.text().trim() !== "'.$map_load_message.'"){ - return; - } - const lat = parseFloat("'.$sede_cliente->lat.'"); const lng = parseFloat("'.$sede_cliente->lng.'"); - - var map = L.map("map-edit", { - center: [lat, lng], - zoom: 10, - gestureHandling: true - }); - + + var container = L.DomUtil.get("map-edit"); + if(container._leaflet_id != null){ + map.eachLayer(function (layer) { + if(layer instanceof L.Marker) { + map.removeLayer(layer); + } + }); + } else { + map = L.map("map-edit", { + gestureHandling: true + }); + + L.tileLayer("'.setting("Tile server OpenStreetMap").'", { + maxZoom: 17, + attribution: "© OpenStreetMap" + }).addTo(map); + } + var icon = new L.Icon({ iconUrl: globals.rootdir + "/assets/dist/img/marker-icon.png", shadowUrl:globals.rootdir + "/assets/dist/img/leaflet/marker-shadow.png", @@ -365,14 +375,11 @@ echo ' shadowSize: [41, 41] }); - L.tileLayer("'.setting("Tile server OpenStreetMap").'", { - maxZoom: 17, - attribution: "© OpenStreetMap" - }).addTo(map); - var marker = L.marker([lat, lng], { icon: icon }).addTo(map); + + map.setView([lat, lng], 10); } function risolviConto(tipo){ diff --git a/modules/anagrafiche/modals/posizione.php b/modules/anagrafiche/modals/posizione.php index 2c8833ac8..dfc4dcabe 100644 --- a/modules/anagrafiche/modals/posizione.php +++ b/modules/anagrafiche/modals/posizione.php @@ -63,11 +63,9 @@ echo ' '; diff --git a/modules/interventi/edit.php b/modules/interventi/edit.php index f25208f8d..97963e28c 100755 --- a/modules/interventi/edit.php +++ b/modules/interventi/edit.php @@ -151,17 +151,19 @@ echo '
'; -$map_load_message = tr('Clicca per visualizzare'); - if (!empty($sede_cliente->gaddress) || (!empty($sede_cliente->lat) && !empty($sede_cliente->lng))) { echo ' -
-

'.$map_load_message.'

-
+

'; + // Navigazione diretta verso l'indirizzo + echo ' + + '.tr('Carica mappa').' + '; + // Navigazione diretta verso l'indirizzo echo ' @@ -230,21 +232,29 @@ echo ' return [lat, lng, indirizzo_default]; } + var map = null; function caricaMappa() { - const map_div = $("#map-edit"); - if (map_div.text().trim() !== "'.$map_load_message.'"){ - return; - } - const lat = parseFloat("'.$sede_cliente->lat.'"); const lng = parseFloat("'.$sede_cliente->lng.'"); - - var map = L.map("map-edit", { - center: [lat, lng], - zoom: 10, - gestureHandling: true - }); - + + var container = L.DomUtil.get("map-edit"); + if(container._leaflet_id != null){ + map.eachLayer(function (layer) { + if(layer instanceof L.Marker) { + map.removeLayer(layer); + } + }); + } else { + map = L.map("map-edit", { + gestureHandling: true + }); + + L.tileLayer("'.setting("Tile server OpenStreetMap").'", { + maxZoom: 17, + attribution: "© OpenStreetMap" + }).addTo(map); + } + var icon = new L.Icon({ iconUrl: globals.rootdir + "/assets/dist/img/marker-icon.png", shadowUrl:globals.rootdir + "/assets/dist/img/leaflet/marker-shadow.png", @@ -254,14 +264,11 @@ echo ' shadowSize: [41, 41] }); - L.tileLayer("'.setting("Tile server OpenStreetMap").'", { - maxZoom: 17, - attribution: "© OpenStreetMap" - }).addTo(map); - var marker = L.marker([lat, lng], { icon: icon }).addTo(map); + + map.setView([lat, lng], 10); } '; diff --git a/plugins/sedi/edit.php b/plugins/sedi/edit.php index 95f7d7cd0..efda73d25 100755 --- a/plugins/sedi/edit.php +++ b/plugins/sedi/edit.php @@ -19,8 +19,6 @@ include_once __DIR__.'/../../core.php'; -$google = setting('Google Maps API key'); - echo '
@@ -104,8 +102,8 @@ echo '
-
- {[ "type": "text", "label": "'.tr('Indirizzo Google').'", "name": "gaddress", "value": "$gaddress$", "extra": "data-geo=\'formatted_address\'" ]} +
+ {[ "type": "text", "label": "'.tr('Indirizzo Mappa').'", "name": "gaddress", "value": "$gaddress$", "extra": "data-geo=\'formatted_address\'" ]}
@@ -114,17 +112,21 @@ echo '
{[ "type": "text", "label": "'.tr('Longitudine').'", "name": "lng", "id": "lng_", "value": "$lng$", "extra": "data-geo=\'lng\'", "class": "text-right" ]} -
'; +
+ +
+
+
'; if (!empty($record['indirizzo']) || (empty($record['citta']))) { echo '

-
   +    '; echo ' - +
'; } @@ -199,24 +201,63 @@ echo '