let draw layer added icons be draggable by default

This commit is contained in:
Dave Conway-Jones 2018-10-13 22:42:52 +01:00
parent 4d870dd38b
commit b511f97e2b
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
5 changed files with 25 additions and 12 deletions

View File

@ -1,8 +1,9 @@
### Change Log for Node-RED Worldmap ### Change Log for Node-RED Worldmap
- v1.5.1 - Make manually added icons moveable by default.
- v1.5.0 - Add multi-map capability - can now have multiple map endpoints. Issue #40 PR #51 - v1.5.0 - Add multi-map capability - can now have multiple map endpoints. Issue #40 PR #51
- Also add built-in world countries overlay layer for offline use. - Also add built-in world countries overlay layer for offline use.
- v1.4.6 - allow more variation in fa-icon modifiers - v1.4.6 - allow more variation in fa-icon modifiers, so fa-3x and fa-spin work.
- v1.4.5 - fix clearing overlays - v1.4.5 - fix clearing overlays
- v1.4.4 - add a couple of extra overlay layers, roads, rail, sea - v1.4.4 - add a couple of extra overlay layers, roads, rail, sea
- v1.4.3 - support custom icon for GPX and KML. Better readme for geojson. - v1.4.3 - support custom icon for GPX and KML. Better readme for geojson.

View File

@ -9,15 +9,16 @@ map web page for plotting "things" on.
### Updates ### Updates
- v1.5.1 - Make manually added icons moveable by default.
- v1.5.0 - Add multi-map capability - can now have multiple map endpoints. - v1.5.0 - Add multi-map capability - can now have multiple map endpoints.
- Also add built-in world countries overlay layer for offline use. - Also add built-in world countries overlay layer for offline use.
- v1.4.6 - allow more variation in fa-icon modifiers - v1.4.6 - allow more variation in fa-icon modifiers, so fa-3x and fa-spin work.
- v1.4.5 - fix clearing overlays - v1.4.5 - fix clearing overlays
- v1.4.4 - add a couple of extra overlay layers, roads, rail, sea - v1.4.4 - add a couple of extra overlay layers, roads, rail, sea
- v1.4.3 - support custom icon for GPX and KML. Better readme for geojson. - v1.4.3 - support custom icon for GPX and KML. Better readme for geojson.
- v1.4.2 - add NVG layer capability - v1.4.2 - add NVG layer capability
- v1.4.1 - let `msg.payload.popup` set the popup contents. - v1.4.1 - let `msg.payload.popup` set the popup contents.
- v1.4.0 - only send to specific _ sessionid if specified. - v1.4.0 - only send to specific \_sessionid if specified.
- v1.3.7 - rescale NATO symbols (less variation, not so small) - v1.3.7 - rescale NATO symbols (less variation, not so small)
- v1.3.6 - setting `msg.payload.draggable = true` will allow a marker to be moved and create a move event on the input node. - v1.3.6 - setting `msg.payload.draggable = true` will allow a marker to be moved and create a move event on the input node.
- v1.3.5 - parse numeric inputs (speed, bearing etc) to remove any extra text. - v1.3.5 - parse numeric inputs (speed, bearing etc) to remove any extra text.

View File

@ -1,10 +1,10 @@
{ {
"name": "node-red-contrib-web-worldmap", "name": "node-red-contrib-web-worldmap",
"version": "1.5.0", "version": "1.5.1",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.", "description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": { "dependencies": {
"cgi": "0.3.1", "cgi": "0.3.1",
"express": "^4.16.3", "express": "^4.16.4",
"sockjs": "^0.3.19" "sockjs": "^0.3.19"
}, },
"repository": { "repository": {

View File

@ -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)})); // 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 rclk;
var addThing = function() { var addThing = function() {
var thing = document.getElementById('rinput').value; var thing = document.getElementById('rinput').value;
//console.log(thing); //console.log(thing);
ws.send(JSON.stringify({action:"point", lat:rclk.lat.toFixed(5), lon:rclk.lng.toFixed(5), point:thing}));
map.closePopup(); map.closePopup();
var bits = thing.split(","); var bits = thing.split(",");
var icon = (bits[1] || "circle").trim(); var icon = (bits[1] || "circle").trim();
var lay = (bits[2] || "drawing").trim(); var lay = (bits[2] || "drawing").trim();
var colo = (bits[3] || "#910000").trim(); var colo = (bits[3] || "#910000").trim();
var drag = !!(bits[4] || false); var drag = true;
var d = {name:bits[0].trim(),layer:lay,icon:icon,iconColor:colo,draggable:drag,lat:rclk.lat,lon:rclk.lng}; var regi = /^[S,G,E,I,O][A-Z]{4}.*/; // if it looks like a SIDC code
setMarker(d); 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]); map.addLayer(layers[lay]);
setMarker(d);
d.action = "point";
ws.send(JSON.stringify(d));
} }
// allow double right click to zoom out // allow double right click to zoom out
@ -1094,8 +1103,10 @@ function setMarker(data) {
if (data.draggable === true) { if (data.draggable === true) {
marker.name = data.name; marker.name = data.name;
marker.icon = data.icon; marker.icon = data.icon;
marker.iconColor = data.iconColor;
marker.SIDC = data.SIDC;
marker.on('dragend', function (e) { 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; } if (data.draggable) { delete data.draggable; }

View File

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
# date: Oct 13th 2018 - v1.5.0 # date: Oct 13th 2018 - v1.5.1
CACHE: CACHE:
index.html index.html