Files
gpx.studio/website/src/lib/components/map/street-view-control/google.ts

33 lines
828 B
TypeScript
Raw Normal View History

2025-10-18 16:10:08 +02:00
import { mapCursor, MapCursorState } from '$lib/logic/map-cursor';
2024-06-24 19:41:44 +02:00
export class GoogleRedirect {
2026-01-30 21:01:24 +01:00
map: maplibregl.Map;
2024-06-24 19:41:44 +02:00
enabled = false;
2026-01-30 21:01:24 +01:00
constructor(map: maplibregl.Map) {
2024-06-24 19:41:44 +02:00
this.map = map;
}
add() {
if (this.enabled) return;
this.enabled = true;
2025-10-18 16:10:08 +02:00
mapCursor.notify(MapCursorState.STREET_VIEW_CROSSHAIR, true);
2024-06-24 19:41:44 +02:00
this.map.on('click', this.openStreetView);
}
remove() {
if (!this.enabled) return;
this.enabled = false;
2025-10-18 16:10:08 +02:00
mapCursor.notify(MapCursorState.STREET_VIEW_CROSSHAIR, false);
2024-06-24 19:41:44 +02:00
this.map.off('click', this.openStreetView);
}
2026-01-30 21:01:24 +01:00
openStreetView(e: maplibregl.MapMouseEvent) {
2024-06-24 19:41:44 +02:00
window.open(
`https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=${e.lngLat.lat},${e.lngLat.lng}`
);
}
}