From 140c5234e455fa9af3efdc839d3436c2fbee16f2 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sun, 5 Dec 2021 09:30:15 +0000 Subject: [PATCH] only show geoobject popup if it has any contents --- worldmap/worldmap.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/worldmap/worldmap.js b/worldmap/worldmap.js index c2769e8..6e38c74 100644 --- a/worldmap/worldmap.js +++ b/worldmap/worldmap.js @@ -1491,6 +1491,13 @@ function setMarker(data) { return; } + if (ll.lat === 0 && ll.lng === 0) { + // Add a little wobble so we can zoom into each if required. + console.log(data.name,"is at null island."); + ll.lat = Math.round(1000000 * ll.lat + Math.random() * 10000 - 5000) / 1000000; + ll.lng = Math.round(1000000 * ll.lng + Math.random() * 10000 - 5000) / 1000000; + } + // Adding new L.LatLng object (lli) when optional intensity value is defined. Only for use in heatmap layer if (typeof data.coordinates == "object") { lli = new L.LatLng(data.coordinates[2],data.coordinates[1],data.coordinates[0]); } else if (data.hasOwnProperty("lat") && data.hasOwnProperty("lon") && data.hasOwnProperty("intensity")) { lli = new L.LatLng((data.lat*1), (data.lon*1), (data.intensity*1)); } @@ -2271,7 +2278,8 @@ function doCommand(cmd) { return st; }}; opt.onEachFeature = function (f,l) { - l.bindPopup('
'+JSON.stringify(f.properties,null,' ').replace(/[\{\}"]/g,'')+'
'); + var pw = '
'+JSON.stringify(f.properties,null,' ').replace(/[\{\}"]/g,'')+'
'; + if (pw.length > 11) { l.bindPopup(pw); } if (cmd.map.hasOwnProperty("clickable") && cmd.map.clickable === true) { l.on('click', function (e) { ws.send(JSON.stringify({action:"clickgeo",name:cmd.map.overlay,type:f.type,properties:f.properties,geometry:f.geometry}));