2020-11-24 01:52:31 +00:00
|
|
|
import L from 'leaflet';
|
|
|
|
import {Coordinate} from "@/dynmap";
|
|
|
|
|
|
|
|
export interface DynmapProjectionOptions {}
|
|
|
|
|
|
|
|
export interface DynmapProjection {
|
|
|
|
locationToLatLng(location: Coordinate): L.LatLng;
|
|
|
|
latLngToLocation(latLng: L.LatLng, y: number): Coordinate;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class DynmapProjection extends L.Class {
|
|
|
|
|
2020-12-01 23:20:38 +00:00
|
|
|
constructor(options?: DynmapProjectionOptions) {
|
2020-11-24 01:52:31 +00:00
|
|
|
super();
|
|
|
|
L.Util.setOptions(this, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
locationToLatLng(location: Coordinate): L.LatLng {
|
2020-12-01 23:20:38 +00:00
|
|
|
return new L.LatLng(location.x, location.z);
|
2020-11-24 01:52:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
latLngToLocation(latLng: L.LatLng, y: number): Coordinate {
|
2020-12-01 23:20:38 +00:00
|
|
|
return {x: latLng.lat, y, z: latLng.lng};
|
2020-11-24 01:52:31 +00:00
|
|
|
}
|
|
|
|
}
|