Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Commit 35e2909

Browse files
author
Explv
committed
Update position calcs for latest tiles
1 parent df0ecaa commit 35e2909

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

js/model/Position.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict';
22

3-
export const MAP_HEIGHT_PX = 296704; // Total height of the map in px at max zoom level
3+
export const MAP_HEIGHT_MAX_ZOOM_PX = 364544;
4+
export const MAP_WIDTH_MAX_ZOOM_PX = 104448;
45
export const RS_TILE_WIDTH_PX = 32, RS_TILE_HEIGHT_PX = 32; // Width and height in px of an rs tile at max zoom level
5-
export const RS_OFFSET_X = 1152; // Amount to offset x coordinate to get correct value
6-
export const RS_OFFSET_Y = 8328; // Amount to offset y coordinate to get correct value
6+
export const RS_OFFSET_X = 1024; // Amount to offset x coordinate to get correct value
7+
export const RS_OFFSET_Y = 6208; // Amount to offset y coordinate to get correct value
78

89
export class Position {
910

@@ -15,7 +16,7 @@ export class Position {
1516

1617
static fromLatLng(map, latLng, z) {
1718
var point = map.project(latLng, map.getMaxZoom());
18-
var y = MAP_HEIGHT_PX - point.y + (RS_TILE_HEIGHT_PX / 4);
19+
var y = MAP_HEIGHT_MAX_ZOOM_PX - point.y + (RS_TILE_HEIGHT_PX / 4);
1920
y = Math.round((y - RS_TILE_HEIGHT_PX) / RS_TILE_HEIGHT_PX) + RS_OFFSET_Y;
2021
var x = Math.round((point.x - RS_TILE_WIDTH_PX) / RS_TILE_WIDTH_PX) + RS_OFFSET_X;
2122
return new Position(x, y, z);
@@ -31,7 +32,7 @@ export class Position {
3132

3233
static toLatLng(map, x, y) {
3334
x = ((x - RS_OFFSET_X) * RS_TILE_WIDTH_PX) + (RS_TILE_WIDTH_PX / 4);
34-
y = (MAP_HEIGHT_PX - ((y - RS_OFFSET_Y) * RS_TILE_HEIGHT_PX));
35+
y = (MAP_HEIGHT_MAX_ZOOM_PX - ((y - RS_OFFSET_Y) * RS_TILE_HEIGHT_PX));
3536
return map.unproject(L.point(x, y), map.getMaxZoom());
3637
}
3738

0 commit comments

Comments
 (0)