0

Ensure coordinates are properly converted when changing views (#1571)

* Ensure coordinates are properly converted when changing views
This commit is contained in:
mircokroon
2019-05-19 11:54:01 +02:00
committed by Nicolas F
parent f1c7ab93f1
commit 2dc8ebd4d9

View File

@@ -221,6 +221,27 @@ overviewer.util = {
'<a href="https://overviewer.org">Overviewer/Leaflet</a>');
overviewer.map.on('baselayerchange', function(ev) {
// when changing the layer, ensure coordinates remain correct
if (overviewer.current_layer[overviewer.current_world]) {
const center = overviewer.map.getCenter();
const currentWorldCoords = overviewer.util.fromLatLngToWorld(
center.lat,
center.lng,
overviewer.current_layer[overviewer.current_world].tileSetConfig);
const newMapCoords = overviewer.util.fromWorldToLatLng(
currentWorldCoords.x,
currentWorldCoords.y,
currentWorldCoords.z,
ev.layer.tileSetConfig);
overviewer.map.setView(
newMapCoords,
overviewer.map.getZoom(),
{ animate: false });
}
// before updating the current_layer, remove the marker control, if it exists
if (overviewer.current_world && overviewer.current_layer[overviewer.current_world]) {
let tsc = overviewer.current_layer[overviewer.current_world].tileSetConfig;