don't re-pan the map when selecting another note that is already on the screen

fixes a regression in #5679
This commit is contained in:
Martin Raifer 2025-02-16 10:36:00 +01:00
parent b14965e4b2
commit a3737b74ba
No known key found for this signature in database
GPG key ID: 3CD561F7B1C461BD

View file

@ -22,16 +22,10 @@ OSM.Note = function (map) {
page.pushstate = page.popstate = function (path, id) {
OSM.loadSidebarContent(path, function () {
initialize(path, id);
var data = $(".details").data();
if (!data) return;
var latLng = L.latLng(data.coordinates.split(","));
if (!map.getBounds().contains(latLng)) {
OSM.router.withoutMoveListener(function () {
map.setView(latLng, 15, { reset: true });
});
}
initialize(path, id, map.getBounds().contains(latLng));
});
};
@ -39,7 +33,7 @@ OSM.Note = function (map) {
initialize(path, id);
};
function initialize(path, id) {
function initialize(path, id, skipMoveToNote) {
content.find("button[name]").on("click", function (e) {
e.preventDefault();
var data = $(e.target).data();
@ -86,7 +80,7 @@ OSM.Note = function (map) {
latLng: L.latLng(data.coordinates.split(",")),
icon: noteIcons[data.status]
}, function () {
if (!hashParams.center) {
if (!hashParams.center && !skipMoveToNote) {
var latLng = L.latLng(data.coordinates.split(","));
OSM.router.withoutMoveListener(function () {
map.setView(latLng, 15, { reset: true });