💄 Trip: focus Place on click, 💄 Navigate to button
This commit is contained in:
parent
e2c57d588b
commit
a64e1d1e06
@ -220,6 +220,9 @@
|
|||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div class="flex items-center gap-2 flex-none">
|
<div class="flex items-center gap-2 flex-none">
|
||||||
|
@if (selectedItem.lat && selectedItem.lng) {
|
||||||
|
<p-button icon="pi pi-car" (click)="itemToNavigation()" text />
|
||||||
|
}
|
||||||
<p-button icon="pi pi-trash" [disabled]="trip?.archived" severity="danger"
|
<p-button icon="pi pi-trash" [disabled]="trip?.archived" severity="danger"
|
||||||
(click)="deleteItem(selectedItem)" text />
|
(click)="deleteItem(selectedItem)" text />
|
||||||
<p-button icon="pi pi-pencil" [disabled]="trip?.archived" (click)="editItem(selectedItem)" text />
|
<p-button icon="pi pi-pencil" [disabled]="trip?.archived" (click)="editItem(selectedItem)" text />
|
||||||
|
|||||||
@ -350,10 +350,10 @@ export class TripComponent implements AfterViewInit {
|
|||||||
this.map?.removeLayer(this.tripMapTemporaryMarker);
|
this.map?.removeLayer(this.tripMapTemporaryMarker);
|
||||||
this.tripMapTemporaryMarker = undefined;
|
this.tripMapTemporaryMarker = undefined;
|
||||||
}
|
}
|
||||||
this.resetMapBounds();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
placeHighlightMarker(lat: number, lng: number) {
|
placeHighlightMarker(lat: number, lng: number) {
|
||||||
|
if (this.tripMapHoveredElement || this.tripMapTemporaryMarker)
|
||||||
this.resetPlaceHighlightMarker();
|
this.resetPlaceHighlightMarker();
|
||||||
|
|
||||||
let marker: L.Marker | undefined;
|
let marker: L.Marker | undefined;
|
||||||
@ -371,15 +371,17 @@ export class TripComponent implements AfterViewInit {
|
|||||||
lng: lng,
|
lng: lng,
|
||||||
};
|
};
|
||||||
this.tripMapTemporaryMarker = tripDayMarker(item).addTo(this.map!);
|
this.tripMapTemporaryMarker = tripDayMarker(item).addTo(this.map!);
|
||||||
this.map?.fitBounds([[lat, lng]], { padding: [30, 30] });
|
this.map?.fitBounds([[lat, lng]], { padding: [60, 60] });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let targetLatLng: L.LatLng | null = null;
|
||||||
const markerElement = marker.getElement() as HTMLElement; // search for Marker. If 'null', is inside Cluster
|
const markerElement = marker.getElement() as HTMLElement; // search for Marker. If 'null', is inside Cluster
|
||||||
if (markerElement) {
|
if (markerElement) {
|
||||||
// marker, not clustered
|
// marker, not clustered
|
||||||
markerElement.classList.add("listHover");
|
markerElement.classList.add("listHover");
|
||||||
this.tripMapHoveredElement = markerElement;
|
this.tripMapHoveredElement = markerElement;
|
||||||
|
targetLatLng = marker.getLatLng();
|
||||||
} else {
|
} else {
|
||||||
// marker is clustered
|
// marker is clustered
|
||||||
const parentCluster = (this.markerClusterGroup as any).getVisibleParent(
|
const parentCluster = (this.markerClusterGroup as any).getVisibleParent(
|
||||||
@ -391,6 +393,18 @@ export class TripComponent implements AfterViewInit {
|
|||||||
clusterEl.classList.add("listHover");
|
clusterEl.classList.add("listHover");
|
||||||
this.tripMapHoveredElement = clusterEl;
|
this.tripMapHoveredElement = clusterEl;
|
||||||
}
|
}
|
||||||
|
targetLatLng = parentCluster.getLatLng();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetLatLng && this.map) {
|
||||||
|
const currentBounds = this.map.getBounds();
|
||||||
|
|
||||||
|
// If point is not inside map bounsd, move map w/o touching zoom
|
||||||
|
if (!currentBounds.contains(targetLatLng)) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.map!.setView(targetLatLng, this.map!.getZoom());
|
||||||
|
}, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -730,6 +744,14 @@ export class TripComponent implements AfterViewInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
itemToNavigation() {
|
||||||
|
if (!this.selectedItem) return;
|
||||||
|
// TODO: More services
|
||||||
|
// const url = `http://maps.apple.com/?daddr=${this.selectedItem.lat},${this.selectedItem.lng}`;
|
||||||
|
const url = `https://www.google.com/maps/dir/?api=1&destination=${this.selectedItem.lat},${this.selectedItem.lng}`;
|
||||||
|
window.open(url, "_blank");
|
||||||
|
}
|
||||||
|
|
||||||
editDay(day: TripDay) {
|
editDay(day: TripDay) {
|
||||||
if (!this.trip) return;
|
if (!this.trip) return;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user