add command.conextmenu for main right click updates

This commit is contained in:
Dave Conway-Jones 2019-03-18 09:01:47 +00:00
parent ed6c383ed1
commit 5c5e8456f6
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4

View File

@ -599,7 +599,8 @@ map.on('zoomend', function() {
//});
// single right click to add a marker
var rightmenuMap = L.popup({keepInView:true, minWidth:250}).setContent("<b>Add marker</b><br><input type='text' id='rinput' autofocus onkeydown='if (event.keyCode == 13) addThing();' placeholder='name (,icon, layer, colour)'/>");
var addmenu = "<b>Add marker</b><br><input type='text' id='rinput' autofocus onkeydown='if (event.keyCode == 13) addThing();' placeholder='name (,icon, layer, colour)'/>";
var rightmenuMap = L.popup({keepInView:true, minWidth:250}).setContent(addmenu);
var rclk;
var hiderightclick = false;
@ -647,7 +648,7 @@ map.on('contextmenu', function(e) {
rclicked = true;
rtout = setTimeout( function() {
rclicked = false;
if (hiderightclick !== true) {
if ((hiderightclick !== true) && (addmenu.length > 0)) {
rclk = e.latlng;
rightmenuMap.setLatLng(e.latlng);
map.openPopup(rightmenuMap);
@ -1514,6 +1515,12 @@ function doCommand(cmd) {
}
}
}
if (cmd.hasOwnProperty("contextmenu")) {
if (typeof cmd.contextmenu === "string") {
addmenu = cmd.contextmenu;
rightmenuMap.setContent(addmenu);
}
}
if (cmd.hasOwnProperty("coords")) {
try { coords.removeFrom(map); }
catch(e) {}