2025-02-02 11:17:22 +01:00
|
|
|
import { resetCursor, setCrosshairCursor } from '$lib/utils';
|
|
|
|
import type mapboxgl from 'mapbox-gl';
|
2024-06-24 19:41:44 +02:00
|
|
|
|
|
|
|
export class GoogleRedirect {
|
|
|
|
map: mapboxgl.Map;
|
|
|
|
enabled = false;
|
|
|
|
|
|
|
|
constructor(map: mapboxgl.Map) {
|
|
|
|
this.map = map;
|
|
|
|
}
|
|
|
|
|
|
|
|
add() {
|
|
|
|
if (this.enabled) return;
|
|
|
|
|
|
|
|
this.enabled = true;
|
|
|
|
setCrosshairCursor();
|
|
|
|
this.map.on('click', this.openStreetView);
|
|
|
|
}
|
|
|
|
|
|
|
|
remove() {
|
|
|
|
if (!this.enabled) return;
|
|
|
|
|
|
|
|
this.enabled = false;
|
|
|
|
resetCursor();
|
|
|
|
this.map.off('click', this.openStreetView);
|
|
|
|
}
|
|
|
|
|
|
|
|
openStreetView(e) {
|
|
|
|
window.open(
|
|
|
|
`https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=${e.lngLat.lat},${e.lngLat.lng}`
|
|
|
|
);
|
|
|
|
}
|
2025-02-02 11:17:22 +01:00
|
|
|
}
|