|
|
|
@ -162,7 +162,7 @@ export class LeafletMapComponent implements OnInit {
|
|
|
|
|
.toPromise();
|
|
|
|
|
|
|
|
|
|
// Ouvrir la modal avec les données pré-remplies
|
|
|
|
|
this.modalService.openModal('add-pin-modal', [], '', {
|
|
|
|
|
this.modalService.openModal('add-pin-modal', [], {
|
|
|
|
|
location: address?.display_name || '',
|
|
|
|
|
complete_address: address?.display_name || '',
|
|
|
|
|
coordinates: [latlng.lat, latlng.lng]
|
|
|
|
@ -170,7 +170,7 @@ export class LeafletMapComponent implements OnInit {
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Erreur lors de la récupération de l\'adresse:', error);
|
|
|
|
|
// En cas d'erreur, ouvrir la modal avec juste les coordonnées
|
|
|
|
|
this.modalService.openModal('add-pin-modal', [], '', {
|
|
|
|
|
this.modalService.openModal('add-pin-modal', [], {
|
|
|
|
|
location: `${latlng.lat}, ${latlng.lng}`,
|
|
|
|
|
complete_address: `${latlng.lat}, ${latlng.lng}`,
|
|
|
|
|
coordinates: [latlng.lat, latlng.lng]
|
|
|
|
@ -270,7 +270,7 @@ export class LeafletMapComponent implements OnInit {
|
|
|
|
|
componentRef.instance.marker = marker;
|
|
|
|
|
popupDiv.appendChild(componentRef.location.nativeElement);
|
|
|
|
|
|
|
|
|
|
marker.bindPopup(popupDiv, { closeButton: false, minWidth: 150 });
|
|
|
|
|
marker.bindPopup(popupDiv, { closeButton: false, minWidth: 200 });
|
|
|
|
|
|
|
|
|
|
this.markersMap[pin.id] = marker;
|
|
|
|
|
|
|
|
|
@ -280,13 +280,16 @@ export class LeafletMapComponent implements OnInit {
|
|
|
|
|
if (pinId) {
|
|
|
|
|
const marker = this.markersMap[pinId];
|
|
|
|
|
if (marker) {
|
|
|
|
|
marker.openPopup();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
marker.openPopup();
|
|
|
|
|
}, 1); // 1ms pour que l'événement popupopen se produise correctement
|
|
|
|
|
|
|
|
|
|
const latlng = marker.getLatLng();
|
|
|
|
|
const zoom = this.map.getZoom();
|
|
|
|
|
const offsetLat = 0.05 / Math.pow(2, zoom - 10);
|
|
|
|
|
this.map.setView(
|
|
|
|
|
L.latLng(latlng.lat + offsetLat, latlng.lng),
|
|
|
|
|
zoom
|
|
|
|
|
L.latLng(latlng.lat + offsetLat, latlng.lng),
|
|
|
|
|
zoom
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|