mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-03-16 17:52:59 +00:00
renaming
This commit is contained in:
33
website/src/lib/components/map/street-view-control/google.ts
Normal file
33
website/src/lib/components/map/street-view-control/google.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { mapCursor, MapCursorState } from '$lib/logic/map-cursor';
|
||||
import type mapboxgl from 'mapbox-gl';
|
||||
|
||||
export class GoogleRedirect {
|
||||
map: mapboxgl.Map;
|
||||
enabled = false;
|
||||
|
||||
constructor(map: mapboxgl.Map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
add() {
|
||||
if (this.enabled) return;
|
||||
|
||||
this.enabled = true;
|
||||
mapCursor.notify(MapCursorState.STREET_VIEW_CROSSHAIR, true);
|
||||
this.map.on('click', this.openStreetView);
|
||||
}
|
||||
|
||||
remove() {
|
||||
if (!this.enabled) return;
|
||||
|
||||
this.enabled = false;
|
||||
mapCursor.notify(MapCursorState.STREET_VIEW_CROSSHAIR, false);
|
||||
this.map.off('click', this.openStreetView);
|
||||
}
|
||||
|
||||
openStreetView(e: mapboxgl.MapMouseEvent) {
|
||||
window.open(
|
||||
`https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=${e.lngLat.lat},${e.lngLat.lng}`
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user