|
|
|
@ -513,22 +513,31 @@ map.on('zoomend', function() {
|
|
|
|
|
// ws.send(JSON.stringify({action:"rightclick", lat:e.latlng.lat.toFixed(5), lon:e.latlng.lng.toFixed(5)}));
|
|
|
|
|
//});
|
|
|
|
|
|
|
|
|
|
var rightmenuMap = L.popup({keepInView:true, minWidth:250}).setContent("<input type='text' id='rinput' onkeydown='if (event.keyCode == 13) addThing();' placeholder='name (,icon, layer, colour, drag(bool))'/>");
|
|
|
|
|
var rightmenuMap = L.popup({keepInView:true, minWidth:250}).setContent("<input type='text' id='rinput' onkeydown='if (event.keyCode == 13) addThing();' placeholder='name (,icon, layer, colour)'/>");
|
|
|
|
|
|
|
|
|
|
var rclk;
|
|
|
|
|
var addThing = function() {
|
|
|
|
|
var thing = document.getElementById('rinput').value;
|
|
|
|
|
//console.log(thing);
|
|
|
|
|
ws.send(JSON.stringify({action:"point", lat:rclk.lat.toFixed(5), lon:rclk.lng.toFixed(5), point:thing}));
|
|
|
|
|
map.closePopup();
|
|
|
|
|
var bits = thing.split(",");
|
|
|
|
|
var icon = (bits[1] || "circle").trim();
|
|
|
|
|
var lay = (bits[2] || "drawing").trim();
|
|
|
|
|
var colo = (bits[3] || "#910000").trim();
|
|
|
|
|
var drag = !!(bits[4] || false);
|
|
|
|
|
var d = {name:bits[0].trim(),layer:lay,icon:icon,iconColor:colo,draggable:drag,lat:rclk.lat,lon:rclk.lng};
|
|
|
|
|
setMarker(d);
|
|
|
|
|
var drag = true;
|
|
|
|
|
var regi = /^[S,G,E,I,O][A-Z]{4}.*/; // if it looks like a SIDC code
|
|
|
|
|
var d;
|
|
|
|
|
if (regi.test(icon)) {
|
|
|
|
|
icon = (icon+"------------").substr(0,12);
|
|
|
|
|
d = {name:bits[0].trim(),layer:lay,SIDC:icon,draggable:drag,lat:rclk.lat,lon:rclk.lng};
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
d = {name:bits[0].trim(),layer:lay,icon:icon,iconColor:colo,draggable:drag,lat:rclk.lat,lon:rclk.lng};
|
|
|
|
|
}
|
|
|
|
|
map.addLayer(layers[lay]);
|
|
|
|
|
setMarker(d);
|
|
|
|
|
d.action = "point";
|
|
|
|
|
ws.send(JSON.stringify(d));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// allow double right click to zoom out
|
|
|
|
@ -1094,8 +1103,10 @@ function setMarker(data) {
|
|
|
|
|
if (data.draggable === true) {
|
|
|
|
|
marker.name = data.name;
|
|
|
|
|
marker.icon = data.icon;
|
|
|
|
|
marker.iconColor = data.iconColor;
|
|
|
|
|
marker.SIDC = data.SIDC;
|
|
|
|
|
marker.on('dragend', function (e) {
|
|
|
|
|
ws.send(JSON.stringify({action:"move",name:marker.name,layer:marker.lay,icon:marker.icon,lat:parseFloat(marker.getLatLng().lat.toFixed(6)),lon:parseFloat(marker.getLatLng().lng.toFixed(6))}));
|
|
|
|
|
ws.send(JSON.stringify({action:"move",name:marker.name,layer:marker.lay,icon:marker.icon,iconColor:marker.iconColor,SIDC:marker.SIDC,lat:parseFloat(marker.getLatLng().lat.toFixed(6)),lon:parseFloat(marker.getLatLng().lng.toFixed(6))}));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (data.draggable) { delete data.draggable; }
|
|
|
|
|