From: Tom Hughes Date: Sun, 9 Oct 2022 17:10:20 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/3747' X-Git-Tag: live~1061 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/685eef338db5a90c1c18a880da2af20681f7328d?hp=206b6c9aefeb2e868db80f559d5022f01283af2b Merge remote-tracking branch 'upstream/pull/3747' --- diff --git a/app/assets/javascripts/index/note.js b/app/assets/javascripts/index/note.js index 8188b8aee..e5eb3a041 100644 --- a/app/assets/javascripts/index/note.js +++ b/app/assets/javascripts/index/note.js @@ -23,8 +23,9 @@ OSM.Note = function (map) { page.pushstate = page.popstate = function (path, id) { OSM.loadSidebarContent(path, function () { initialize(path, id, function () { - var data = $(".details").data(), - latLng = L.latLng(data.coordinates.split(",")); + var data = $(".details").data(); + if (!data) return; + var latLng = L.latLng(data.coordinates.split(",")); if (!map.getBounds().contains(latLng)) moveToNote(); }); }); @@ -71,19 +72,22 @@ OSM.Note = function (map) { var data = $(".details").data(); - map.addObject({ - type: "note", - id: parseInt(id, 10), - latLng: L.latLng(data.coordinates.split(",")), - icon: noteIcons[data.status] - }); + if (data) { + map.addObject({ + type: "note", + id: parseInt(id, 10), + latLng: L.latLng(data.coordinates.split(",")), + icon: noteIcons[data.status] + }); + } if (callback) callback(); } function moveToNote() { - var data = $(".details").data(), - latLng = L.latLng(data.coordinates.split(",")); + 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 () {