This is useful because everywhere that we use the AddressAndMapLocator component we also want to use the user's location and we want to zoom the map based on their location. Instead of tracking this externally in 3 places we just pull it into the component.
30 lines
679 B
TypeScript
30 lines
679 B
TypeScript
import maplibregl from "maplibre-gl";
|
|
import { Address, Location } from "@/type/api";
|
|
|
|
export class Camera {
|
|
location: Location;
|
|
zoom: number;
|
|
constructor(location: Location = new Location(), zoom: number = 0) {
|
|
this.location = location;
|
|
this.zoom = zoom;
|
|
}
|
|
}
|
|
export class Locator {
|
|
address: Address;
|
|
location: Location;
|
|
constructor(
|
|
address: Address = new Address(),
|
|
location: Location = new Location(),
|
|
) {
|
|
this.address = address;
|
|
this.location = location;
|
|
}
|
|
}
|
|
export type MoveEndEventInternal = maplibregl.MapLibreEvent<
|
|
| maplibregl.MapMouseEvent
|
|
| maplibregl.MapTouchEvent
|
|
| maplibregl.MapWheelEvent
|
|
| undefined
|
|
> & {
|
|
isInternalUpdate: boolean;
|
|
};
|