|
|
|
@ -24,7 +24,7 @@ export class LeafletMapComponent implements OnInit {
|
|
|
|
|
availableCountries: string[] = [];
|
|
|
|
|
availablePersons: string[] = [];
|
|
|
|
|
selectedCountry: string = '';
|
|
|
|
|
selectedPerson: string = '';
|
|
|
|
|
selectedPerson: string = '__all__';
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
private viewContainerRef: ViewContainerRef,
|
|
|
|
@ -36,6 +36,20 @@ export class LeafletMapComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
this.initializeMap();
|
|
|
|
|
|
|
|
|
|
this.route.queryParams.subscribe((params) => {
|
|
|
|
|
const pinId = params['pin'];
|
|
|
|
|
if (pinId) {
|
|
|
|
|
const marker = this.markersMap[pinId];
|
|
|
|
|
if (marker) {
|
|
|
|
|
marker.openPopup();
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private initializeMap(): void {
|
|
|
|
@ -132,9 +146,13 @@ export class LeafletMapComponent implements OnInit {
|
|
|
|
|
const matchesCountry = this.selectedCountry
|
|
|
|
|
? pinCountry === this.selectedCountry
|
|
|
|
|
: true;
|
|
|
|
|
const matchesPerson = this.selectedPerson
|
|
|
|
|
? pin.description?.includes(`@${this.selectedPerson}`)
|
|
|
|
|
: true;
|
|
|
|
|
const matchesPerson =
|
|
|
|
|
this.selectedPerson === '__all__'
|
|
|
|
|
? true
|
|
|
|
|
: this.selectedPerson === '__none__'
|
|
|
|
|
? !pin.description?.match(/@\w+/)
|
|
|
|
|
: pin.description?.includes(`@${this.selectedPerson}`);
|
|
|
|
|
|
|
|
|
|
return matchesCountry && matchesPerson;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -162,17 +180,24 @@ export class LeafletMapComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
this.markersMap[pin.id] = marker;
|
|
|
|
|
|
|
|
|
|
// Ouvrir automatiquement la pop-up si un ID est passé dans l'URL
|
|
|
|
|
this.route.queryParams.subscribe((params) => {
|
|
|
|
|
const pinId = params['pin']; // Récupérer l'ID du Pin depuis les paramètres de requête
|
|
|
|
|
if (pinId && this.markersMap[pinId]) {
|
|
|
|
|
this.markersMap[pinId].openPopup(); // Ouvrir la pop-up du marqueur correspondant
|
|
|
|
|
const latlng = this.markersMap[pinId].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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.route.queryParams
|
|
|
|
|
.subscribe((params) => {
|
|
|
|
|
const pinId = params['pin'];
|
|
|
|
|
if (pinId) {
|
|
|
|
|
const marker = this.markersMap[pinId];
|
|
|
|
|
if (marker) {
|
|
|
|
|
marker.openPopup();
|
|
|
|
|
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
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.unsubscribe();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|