mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 10:20:16 +01:00
implemented a map zone selector based on squares
This commit is contained in:
20
traque-front/components/util/map.jsx
Normal file
20
traque-front/components/util/map.jsx
Normal file
@@ -0,0 +1,20 @@
|
||||
export class TileNumber {
|
||||
constructor(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
equals(other) {
|
||||
return this.x === other.x && this.y === other.y;
|
||||
}
|
||||
}
|
||||
|
||||
export function latLngToTileNumber(latLng, tileSize) {
|
||||
const numTilesX = 2 ** tileSize;
|
||||
const numTilesY = 2 ** tileSize;
|
||||
const lngDegrees = latLng.lng;
|
||||
const latRadians = latLng.lat * (Math.PI / 180);
|
||||
return new L.Point(
|
||||
numTilesX * ((lngDegrees + 180) / 360),
|
||||
numTilesY * (1 - Math.log(Math.tan(latRadians) + 1 / Math.cos(latRadians)) / Math.PI) / 2
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user