From 68e46673afdf343c9bf61fe69d7a9b2a43ec088d Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 26 Apr 2019 00:07:41 +0100 Subject: [PATCH] refix right context menu to close #92 --- worldmap/index.html | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/worldmap/index.html b/worldmap/index.html index 8dce650..b426472 100644 --- a/worldmap/index.html +++ b/worldmap/index.html @@ -1435,7 +1435,7 @@ function setMarker(data) { // customise right click context menu var rightcontext = ""; if ((data.contextmenu !== undefined) && (typeof data.contextmenu === "string")) { - rightcontext = data.contextmenu.replace(/$name/g,'\""+'+data.name+'+"\"'); + rightcontext = data.contextmenu.replace(/\$name/g,data.name); delete data.contextmenu; } @@ -1467,13 +1467,18 @@ function setMarker(data) { marker._popup.dname = data.name; marker.lay = lay; // and the layer it is on - var rightmenuMarker = L.popup({offset:[0,-12]}).setContent(""+data.name+"
"); - marker.on('contextmenu', function(e) { - if (hiderightclick !== true) { - rightmenuMarker.setLatLng(e.latlng); - map.openPopup(rightmenuMarker); - } - }); + if (rightcontext.length === 0) { + marker.on('contextmenu', function() { return; }); + } + else { + var rightmenuMarker = L.popup({offset:[0,-12]}).setContent(""+data.name+"
"+rightcontext); + marker.on('contextmenu', function(e) { + if (hiderightclick !== true) { + rightmenuMarker.setLatLng(e.latlng); + map.openPopup(rightmenuMarker); + } + }); + } marker.on('click', function(e) { ws.send(JSON.stringify({action:"click",name:marker.name,layer:marker.lay,icon:marker.icon,iconColor:marker.iconColor,SIDC:marker.SIDC,draggable:true,lat:parseFloat(marker.getLatLng().lat.toFixed(6)),lon:parseFloat(marker.getLatLng().lng.toFixed(6))})); });