Ensure coordinates are properly converted when changing views (#1571)
* Ensure coordinates are properly converted when changing views
This commit is contained in:
@@ -221,6 +221,27 @@ overviewer.util = {
|
|||||||
'<a href="https://overviewer.org">Overviewer/Leaflet</a>');
|
'<a href="https://overviewer.org">Overviewer/Leaflet</a>');
|
||||||
|
|
||||||
overviewer.map.on('baselayerchange', function(ev) {
|
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
|
// before updating the current_layer, remove the marker control, if it exists
|
||||||
if (overviewer.current_world && overviewer.current_layer[overviewer.current_world]) {
|
if (overviewer.current_world && overviewer.current_layer[overviewer.current_world]) {
|
||||||
let tsc = overviewer.current_layer[overviewer.current_world].tileSetConfig;
|
let tsc = overviewer.current_layer[overviewer.current_world].tileSetConfig;
|
||||||
|
|||||||
Reference in New Issue
Block a user