LiveAtlas/src/leaflet/projection/DynmapProjection.ts

26 lines
621 B
TypeScript
Raw Normal View History

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) {
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);
}
latLngToLocation(latLng: L.LatLng, y: number): Coordinate {
2020-12-01 23:20:38 +00:00
return {x: latLng.lat, y, z: latLng.lng};
}
}