show icon in circle if requested

to close #128
This commit is contained in:
Dave Conway-Jones 2020-04-19 21:51:51 +01:00
parent 8f51fa21ae
commit 99ed6f859b
No known key found for this signature in database
GPG Key ID: 302A6725C594817F
6 changed files with 29 additions and 26 deletions

View File

@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap ### Change Log for Node-RED Worldmap
- v2.3.7 - show icon within circle if icon present. Issue #128
- v2.3.6 - show ruler if grid is turned on. - v2.3.6 - show ruler if grid is turned on.
- v2.3.5 - Let tracks node handle array of points. Let http icons be rotated to hdg or bearing. - v2.3.5 - Let tracks node handle array of points. Let http icons be rotated to hdg or bearing.
- v2.3.4 - Add bus icon - v2.3.4 - Add bus icon
@ -8,7 +9,7 @@
- v2.3.1 - Stop adding point when you add a circle - v2.3.1 - Stop adding point when you add a circle
- v2.3.0 - Add colour options for drawing layer - v2.3.0 - Add colour options for drawing layer
- v2.2.1 - Better implementation of legend create/show/hide - v2.2.1 - Better implementation of legend create/show/hide
- v2.2.0 - Add rangering arcs function - v2.2.0 - Add range rings and arcs function
- v2.1.6 - Add legend command to allow inserting an html legend - v2.1.6 - Add legend command to allow inserting an html legend
- v2.1.5 - Fix squawk icon color handling - v2.1.5 - Fix squawk icon color handling
- v2.1.4 - Fix alt and speed as strings - v2.1.4 - Fix alt and speed as strings

View File

@ -10,6 +10,8 @@ map web page for plotting "things" on.
### Updates ### Updates
- v2.3.7 - show icon within circle if icon present. Issue #128
- v2.3.6 - show ruler if grid is turned on.
- v2.3.5 - Let tracks node handle array of points. Let http icons be rotated to hdg or bearing. - v2.3.5 - Let tracks node handle array of points. Let http icons be rotated to hdg or bearing.
- v2.3.4 - Add bus icon - v2.3.4 - Add bus icon
- v2.3.3 - Fix satellite view max zoom - v2.3.3 - Fix satellite view max zoom
@ -17,7 +19,7 @@ map web page for plotting "things" on.
- v2.3.1 - Stop adding point when you add a circle - v2.3.1 - Stop adding point when you add a circle
- v2.3.0 - Add colour options for drawing layer - v2.3.0 - Add colour options for drawing layer
- v2.2.1 - Better implementation of legend create/show/hide - v2.2.1 - Better implementation of legend create/show/hide
- v2.2.0 - Add rangerings arcs function - v2.2.0 - Add range rings and arcs function
- v2.1.6 - Add legend command to allow inserting an html legend - v2.1.6 - Add legend command to allow inserting an html legend
- v2.1.5 - Fix squawk icon color handling - v2.1.5 - Fix squawk icon color handling
- v2.1.4 - Fix alt and speed as strings - v2.1.4 - Fix alt and speed as strings

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-contrib-web-worldmap", "name": "node-red-contrib-web-worldmap",
"version": "2.3.6", "version": "2.3.7",
"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",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -522,7 +522,7 @@ function showMapCurrentZoom() {
} }
} }
try { try {
if (polygons[key].hasOwnProperty("_layers")) { if (polygons[key].hasOwnProperty("_layers")) {
polygons[key].eachLayer(function(layer) { layer.redraw(); }); polygons[key].eachLayer(function(layer) { layer.redraw(); });
} }
else { else {
@ -1097,8 +1097,10 @@ function setMarker(data) {
polycirc = L.circle(new L.LatLng((data.lat*1), (data.lon*1)), data.radius*1, opt); polycirc = L.circle(new L.LatLng((data.lat*1), (data.lon*1)), data.radius*1, opt);
} }
polygons[data.name] = polycirc; polygons[data.name] = polycirc;
delete (data.lat); if (!data.hasOwnProperty("icon")) {
delete (data.lon); delete (data.lat);
delete (data.lon);
}
} }
} }
else if (data.hasOwnProperty("arc")) { else if (data.hasOwnProperty("arc")) {
@ -1132,9 +1134,9 @@ function setMarker(data) {
} }
else if (data.hasOwnProperty("lat") && data.hasOwnProperty("lon")) { ll = new L.LatLng((data.lat*1), (data.lon*1)); } else if (data.hasOwnProperty("lat") && data.hasOwnProperty("lon")) { ll = new L.LatLng((data.lat*1), (data.lon*1)); }
else if (data.hasOwnProperty("latitude") && data.hasOwnProperty("longitude")) { ll = new L.LatLng((data.latitude*1), (data.longitude*1)); } else if (data.hasOwnProperty("latitude") && data.hasOwnProperty("longitude")) { ll = new L.LatLng((data.latitude*1), (data.longitude*1)); }
else { else {
// console.log("No location:",data); // console.log("No location:",data);
return; return;
} }
// Adding new L.LatLng object (lli) when optional intensity value is defined. Only for use in heatmap layer // Adding new L.LatLng object (lli) when optional intensity value is defined. Only for use in heatmap layer
@ -1164,9 +1166,9 @@ function setMarker(data) {
} }
else if (data.icon === "plane") { else if (data.icon === "plane") {
data.iconColor = data.iconColor || "black"; data.iconColor = data.iconColor || "black";
if (data.hasOwnProperty("squawk")) { if (data.hasOwnProperty("squawk")) {
if (data.squawk == 7500 || data.squawk == 7600 || data.squawk == 7700) { if (data.squawk == 7500 || data.squawk == 7600 || data.squawk == 7700) {
data.iconColor = "red"; data.iconColor = "red";
} }
} }
icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="310px" height="310px" viewBox="0 0 310 310">'; icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="310px" height="310px" viewBox="0 0 310 310">';
@ -1200,9 +1202,9 @@ function setMarker(data) {
} }
else if (data.icon === "helicopter") { else if (data.icon === "helicopter") {
data.iconColor = data.iconColor || "black"; data.iconColor = data.iconColor || "black";
if (data.hasOwnProperty("squawk")) { if (data.hasOwnProperty("squawk")) {
if (data.squawk == 7500 || data.squawk == 7600 || data.squawk == 7700) { if (data.squawk == 7500 || data.squawk == 7600 || data.squawk == 7700) {
data.iconColor = "red"; data.iconColor = "red";
} }
} }
icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="314" height="314" viewBox="0 0 314.5 314.5">'; icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="314" height="314" viewBox="0 0 314.5 314.5">';
@ -1218,9 +1220,9 @@ function setMarker(data) {
} }
else if (data.icon === "uav") { else if (data.icon === "uav") {
data.iconColor = data.iconColor || "black"; data.iconColor = data.iconColor || "black";
if (data.hasOwnProperty("squawk")) { if (data.hasOwnProperty("squawk")) {
if (data.squawk == 7500 || data.squawk == 7600 || data.squawk == 7700) { if (data.squawk == 7500 || data.squawk == 7600 || data.squawk == 7700) {
data.iconColor = "red"; data.iconColor = "red";
} }
} }
icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 100">'; icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 100">';
@ -1558,8 +1560,8 @@ function setMarker(data) {
if (data.bearing != null) { // if there is a heading if (data.bearing != null) { // if there is a heading
if (data.speed != null) { data.length = parseFloat(data.speed || "0") * 50; } // and a speed if (data.speed != null) { data.length = parseFloat(data.speed || "0") * 50; } // and a speed
if (data.length != null) { if (data.length != null) {
if (polygons[data.name] != null && !polygons[data.name].hasOwnProperty("_layers")) { if (polygons[data.name] != null && !polygons[data.name].hasOwnProperty("_layers")) {
map.removeLayer(polygons[data.name]); map.removeLayer(polygons[data.name]);
} }
var x = ll.lng * 1; // X coordinate var x = ll.lng * 1; // X coordinate
var y = ll.lat * 1; // Y coordinate var y = ll.lat * 1; // Y coordinate
@ -1589,10 +1591,10 @@ function setMarker(data) {
} }
} }
if (polygons[data.name] != null && polygons[data.name].hasOwnProperty("_layers")) { if (polygons[data.name] != null && polygons[data.name].hasOwnProperty("_layers")) {
polygons[data.name].addLayer(polygon); polygons[data.name].addLayer(polygon);
} }
else { else {
polygons[data.name] = polygon; polygons[data.name] = polygon;
} }
polygons[data.name].lay = lay; polygons[data.name].lay = lay;
layers[lay].addLayer(polygon); layers[lay].addLayer(polygon);
@ -1710,9 +1712,9 @@ function doCommand(cmd) {
}; };
legend.getContainer().style.visibility = 'visible'; // if already exist use visibility to show/hide legend.getContainer().style.visibility = 'visible'; // if already exist use visibility to show/hide
legend.getContainer().innerHTML = cmd.legend; // set content of legend legend.getContainer().innerHTML = cmd.legend; // set content of legend
} }
else { else {
if (legend.getContainer()) { if (legend.getContainer()) {
legend.getContainer().style.visibility = 'hidden'; //if empty string and legend already created hide it legend.getContainer().style.visibility = 'hidden'; //if empty string and legend already created hide it
} }
} }
@ -2051,7 +2053,7 @@ function doGeojson(g,l,o) {
if (!basemaps[glayer]) { if (!basemaps[glayer]) {
var opt = { style: function(feature) { var opt = { style: function(feature) {
var st = { stroke:true, color:"#910000", weight:2, fill:true, fillColor:"#910000", fillOpacity:0.3 }; var st = { stroke:true, color:"#910000", weight:2, fill:true, fillColor:"#910000", fillOpacity:0.3 };
st = Object.assign(st,o); st = Object.assign(st,o);
if (feature.hasOwnProperty("properties")) { if (feature.hasOwnProperty("properties")) {
console.log("GPROPS", feature.properties) console.log("GPROPS", feature.properties)
} }