From 6616d5e1bab2c5e8db39a1aefe978c57fc7b3a0f Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Sun, 9 Oct 2022 09:08:45 +0300 Subject: [PATCH] Don't scroll to or show markers of notes with no data --- app/assets/javascripts/index/note.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) 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 () { -- 2.39.5