var data = $(".details").data();
if (!data) return;
var latLng = L.latLng(data.coordinates.split(","));
- if (!map.getBounds().contains(latLng)) moveToNote();
+ if (!map.getBounds().contains(latLng)) {
+ OSM.router.withoutMoveListener(function () {
+ map.setView(latLng, 15, { reset: true });
+ });
+ }
});
};
page.load = function (path, id) {
initialize(path, id);
- moveToNote();
};
function initialize(path, id) {
success: () => {
OSM.loadSidebarContent(path, () => {
initialize(path, id);
- moveToNote();
});
},
error: (xhr) => {
var data = $(".details").data();
if (data) {
+ var hashParams = OSM.parseHash(window.location.hash);
map.addObject({
type: "note",
id: parseInt(id, 10),
latLng: L.latLng(data.coordinates.split(",")),
icon: noteIcons[data.status]
+ }, function () {
+ if (!hashParams.center) {
+ var latLng = L.latLng(data.coordinates.split(","));
+ OSM.router.withoutMoveListener(function () {
+ map.setView(latLng, 15, { reset: true });
+ });
+ }
});
}
}
}
}
- function moveToNote() {
- var data = $(".details").data();
- if (!data) return;
- var latLng = L.latLng(data.coordinates.split(","));
-
- if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) {
- OSM.router.withoutMoveListener(function () {
- map.setView(latLng, 15, { reset: true });
- });
- }
- }
-
page.unload = function () {
map.removeObject();
};