node-red-contrib-web-worldmap 4.3.1 → 4.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +2 -0
- package/package.json +1 -1
- package/worldmap/worldmap.js +96 -83
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
### Change Log for Node-RED Worldmap
|
|
2
2
|
|
|
3
|
+
- v4.3.3 - Fix for objects changing layers.
|
|
4
|
+
- v4.3.2 - Fix geojson popup missing label name.
|
|
3
5
|
- v4.3.1 - Small fix to icon transparency, and routing detail.
|
|
4
6
|
- v4.3.0 - Add support for PMtiles files.
|
|
5
7
|
- v4.2.1 - Revert use of optional chaining to extend life slightly. Issue #252
|
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@ Feel free to [;
|
|
|
117
117
|
|
|
118
118
|
var handleData = function(data) {
|
|
119
119
|
if (Array.isArray(data)) {
|
|
120
|
-
//console.log("ARRAY");
|
|
120
|
+
//console.log("ARRAY:",data.length);
|
|
121
121
|
for (var prop in data) {
|
|
122
122
|
if (data[prop].command) { doCommand(data[prop].command); delete data[prop].command; }
|
|
123
123
|
if (data[prop].hasOwnProperty("name")) {
|
|
@@ -1502,28 +1502,30 @@ var rangerings = function(latlng, options) {
|
|
|
1502
1502
|
function setMarker(data) {
|
|
1503
1503
|
var rightmenu = function(m) {
|
|
1504
1504
|
m.on('click', function(e) {
|
|
1505
|
-
var fb = allData[data
|
|
1505
|
+
var fb = allData[data["name"]];
|
|
1506
1506
|
fb.action = "click";
|
|
1507
1507
|
ws.send(JSON.stringify(fb));
|
|
1508
1508
|
});
|
|
1509
1509
|
// customise right click context menu
|
|
1510
1510
|
var rightcontext = "";
|
|
1511
|
-
//if (polygons[data
|
|
1512
|
-
rightcontext = "<button id='delbutton' onclick='delMarker(\""+data
|
|
1511
|
+
//if (polygons[data["name"]] == undefined) {
|
|
1512
|
+
rightcontext = "<button id='delbutton' onclick='delMarker(\""+data["name"]+"\",true);'>Delete</button>";
|
|
1513
1513
|
//}
|
|
1514
1514
|
if (data.editable) {
|
|
1515
|
-
rightcontext = "<button onclick='editPoly(\""+data
|
|
1515
|
+
rightcontext = "<button onclick='editPoly(\""+data["name"]+"\");'>Edit</button><button onclick='delMarker(\""+data["name"]+"\",true);'>Delete</button>";
|
|
1516
1516
|
}
|
|
1517
1517
|
if ((data.contextmenu !== undefined) && (typeof data.contextmenu === "string")) {
|
|
1518
|
-
rightcontext = data.contextmenu.replace(/\${name}/g,data
|
|
1518
|
+
rightcontext = data.contextmenu.replace(/\${name}/g,data["name"]);
|
|
1519
1519
|
delete data.contextmenu;
|
|
1520
1520
|
}
|
|
1521
|
-
|
|
1522
|
-
|
|
1521
|
+
if (allData.hasOwnProperty(data["name"]) && allData[data["name"]].hasOwnProperty("value")) {
|
|
1522
|
+
for (const item in allData[data["name"]].value) {
|
|
1523
|
+
rightcontext = rightcontext.replace(new RegExp("\\${"+item+"}","g"),allData[data["name"]].value[item]);
|
|
1524
|
+
}
|
|
1523
1525
|
}
|
|
1524
1526
|
rightcontext = rightcontext.replace(/\${.*?}/g,'')
|
|
1525
1527
|
if (rightcontext.length > 0) {
|
|
1526
|
-
var rightmenuMarker = L.popup({offset:[0,-12]}).setContent("<b>"+data
|
|
1528
|
+
var rightmenuMarker = L.popup({offset:[0,-12]}).setContent("<b>"+data["name"]+"</b><br/>"+rightcontext);
|
|
1527
1529
|
if (hiderightclick !== true) {
|
|
1528
1530
|
m.on('contextmenu', function(e) {
|
|
1529
1531
|
L.DomEvent.stopPropagation(e);
|
|
@@ -1544,7 +1546,7 @@ function setMarker(data) {
|
|
|
1544
1546
|
|
|
1545
1547
|
// console.log("DATA", typeof data, data);
|
|
1546
1548
|
if (data.deleted == true) { // remove markers we are told to
|
|
1547
|
-
delMarker(data
|
|
1549
|
+
delMarker(data["name"]);
|
|
1548
1550
|
return;
|
|
1549
1551
|
}
|
|
1550
1552
|
|
|
@@ -1576,8 +1578,8 @@ function setMarker(data) {
|
|
|
1576
1578
|
}
|
|
1577
1579
|
|
|
1578
1580
|
var lll = "unknown";
|
|
1579
|
-
if (markers.hasOwnProperty(data
|
|
1580
|
-
lll = markers[data
|
|
1581
|
+
if (markers.hasOwnProperty(data["name"]) && markers[data["name"]].hasOwnProperty("lay")) {
|
|
1582
|
+
lll = markers[data["name"]].lay;
|
|
1581
1583
|
}
|
|
1582
1584
|
var lay = data.layer ?? lll;
|
|
1583
1585
|
if (!data.hasOwnProperty("action") || data.action.indexOf("layer") === -1) {
|
|
@@ -1600,27 +1602,27 @@ function setMarker(data) {
|
|
|
1600
1602
|
map.addLayer(overlays[lay]);
|
|
1601
1603
|
//console.log("ADDED LAYER",lay,layers);
|
|
1602
1604
|
}
|
|
1603
|
-
if (!allData.hasOwnProperty(data
|
|
1605
|
+
if (!allData.hasOwnProperty(data["name"])) { allData[data["name"]] = {}; }
|
|
1604
1606
|
delete data.action;
|
|
1605
1607
|
Object.keys(data).forEach(function(key) {
|
|
1606
|
-
if (data[key] == null) { delete allData[data
|
|
1607
|
-
else { allData[data
|
|
1608
|
+
if (data[key] == null) { delete allData[data["name"]][key]; }
|
|
1609
|
+
else { allData[data["name"]][key] = data[key]; }
|
|
1608
1610
|
});
|
|
1609
|
-
data = Object.assign({},allData[data
|
|
1611
|
+
data = Object.assign({},allData[data["name"]]);
|
|
1610
1612
|
}
|
|
1611
1613
|
delete data.action;
|
|
1612
1614
|
|
|
1613
|
-
if (typeof markers[data
|
|
1614
|
-
if (markers[data
|
|
1615
|
-
delMarker(data
|
|
1615
|
+
if (typeof markers[data["name"]] != "undefined") {
|
|
1616
|
+
if (markers[data["name"]].lay !== lay) {
|
|
1617
|
+
delMarker(data["name"]);
|
|
1616
1618
|
}
|
|
1617
1619
|
else {
|
|
1618
|
-
try {layers[lay].removeLayer(markers[data
|
|
1620
|
+
try {layers[lay].removeLayer(markers[data["name"]]); }
|
|
1619
1621
|
catch(e) { console.log("OOPS"); }
|
|
1620
1622
|
}
|
|
1621
1623
|
}
|
|
1622
1624
|
|
|
1623
|
-
if (typeof polygons[data
|
|
1625
|
+
if (typeof polygons[data["name"]] != "undefined") { layers[lay].removeLayer(polygons[data["name"]]); }
|
|
1624
1626
|
|
|
1625
1627
|
if (data.hasOwnProperty("drawCount")) { drawCount = data.drawCount; }
|
|
1626
1628
|
// Draw lines
|
|
@@ -1629,14 +1631,14 @@ function setMarker(data) {
|
|
|
1629
1631
|
if (!data.hasOwnProperty("weight")) { opt.weight = 3; } //Standard settings different for lines
|
|
1630
1632
|
if (!data.hasOwnProperty("opacity")) { opt.opacity = 0.8; }
|
|
1631
1633
|
var polyln = L.polyline(data.line, opt);
|
|
1632
|
-
polygons[data
|
|
1634
|
+
polygons[data["name"]] = rightmenu(polyln);
|
|
1633
1635
|
}
|
|
1634
1636
|
// Draw Areas
|
|
1635
1637
|
else if (data.hasOwnProperty("area") && Array.isArray(data.area)) {
|
|
1636
1638
|
var polyarea;
|
|
1637
1639
|
if (data.area.length === 2) { polyarea = L.rectangle(data.area, opt); }
|
|
1638
1640
|
else { polyarea = L.polygon(data.area, opt); }
|
|
1639
|
-
polygons[data
|
|
1641
|
+
polygons[data["name"]] = rightmenu(polyarea);
|
|
1640
1642
|
}
|
|
1641
1643
|
// Draw Great circles
|
|
1642
1644
|
if (data.hasOwnProperty("greatcircle") && Array.isArray(data.greatcircle) && data.greatcircle.length === 2) {
|
|
@@ -1646,14 +1648,14 @@ function setMarker(data) {
|
|
|
1646
1648
|
if (!data.hasOwnProperty("opacity")) { opt.opacity = 0.8; }
|
|
1647
1649
|
var greatc = L.Polyline.Arc(data.greatcircle[0], data.greatcircle[1], opt);
|
|
1648
1650
|
var aml = new L.Wrapped.Polyline(greatc._latlngs, opt);
|
|
1649
|
-
polygons[data
|
|
1651
|
+
polygons[data["name"]] = rightmenu(aml);
|
|
1650
1652
|
}
|
|
1651
1653
|
// Draw error ellipses
|
|
1652
1654
|
else if (data.hasOwnProperty("sdlat") && data.hasOwnProperty("sdlon")) {
|
|
1653
1655
|
if (!data.hasOwnProperty("iconColor")) { opt.color = "blue"; } //different standard Color Settings
|
|
1654
1656
|
if (!data.hasOwnProperty("fillColor")) { opt.fillColor = "blue"; }
|
|
1655
1657
|
var ellipse = L.ellipse(new L.LatLng((data.lat*1), (data.lon*1)), [200000*data.sdlon*Math.cos(data.lat*Math.PI/180), 200000*data.sdlat], 0, opt);
|
|
1656
|
-
polygons[data
|
|
1658
|
+
polygons[data["name"]] = rightmenu(ellipse);
|
|
1657
1659
|
}
|
|
1658
1660
|
// Draw circles and ellipses
|
|
1659
1661
|
else if (data.hasOwnProperty("radius")) {
|
|
@@ -1665,7 +1667,7 @@ function setMarker(data) {
|
|
|
1665
1667
|
else {
|
|
1666
1668
|
polycirc = L.circle(new L.LatLng((data.lat*1), (data.lon*1)), data.radius*1, opt);
|
|
1667
1669
|
}
|
|
1668
|
-
polygons[data
|
|
1670
|
+
polygons[data["name"]] = rightmenu(polycirc);
|
|
1669
1671
|
if (!data.hasOwnProperty("icon")) {
|
|
1670
1672
|
delete (data.lat);
|
|
1671
1673
|
delete (data.lon);
|
|
@@ -1675,34 +1677,34 @@ function setMarker(data) {
|
|
|
1675
1677
|
// Draw arcs (and range rings)
|
|
1676
1678
|
else if (data.hasOwnProperty("arc")) {
|
|
1677
1679
|
if (data.hasOwnProperty("lat") && data.hasOwnProperty("lon")) {
|
|
1678
|
-
polygons[data
|
|
1680
|
+
polygons[data["name"]] = rangerings(new L.LatLng((data.lat*1), (data.lon*1)), data.arc);
|
|
1679
1681
|
}
|
|
1680
1682
|
}
|
|
1681
1683
|
// Draw a geojson "shape"
|
|
1682
1684
|
else if (data.hasOwnProperty("geojson")) {
|
|
1683
|
-
doGeojson(data
|
|
1685
|
+
doGeojson(data["name"],data.geojson,(data.layer || "unknown"),opt);
|
|
1684
1686
|
}
|
|
1685
1687
|
|
|
1686
1688
|
// If we created a shape then apply some generic things to it
|
|
1687
|
-
if (polygons[data
|
|
1689
|
+
if (polygons[data["name"]] !== undefined) {
|
|
1688
1690
|
// Set the layer
|
|
1689
|
-
polygons[data
|
|
1691
|
+
polygons[data["name"]].lay = lay;
|
|
1690
1692
|
// if clickable then add popup
|
|
1691
1693
|
if (opt.clickable === true) {
|
|
1692
|
-
var words = "<b>"+data
|
|
1694
|
+
var words = "<b>"+data["name"]+"</b>";
|
|
1693
1695
|
if (data.popup) { words = words + "<br/>" + data.popup; }
|
|
1694
|
-
polygons[data
|
|
1696
|
+
polygons[data["name"]].bindPopup(words, {autoClose:false, closeButton:true, closeOnClick:true, minWidth:200});
|
|
1695
1697
|
}
|
|
1696
1698
|
// add a tooltip (if supplied)
|
|
1697
|
-
if (data.hasOwnProperty("tooltip")) { polygons[data
|
|
1699
|
+
if (data.hasOwnProperty("tooltip")) { polygons[data["name"]].bindTooltip(data.tooltip); }
|
|
1698
1700
|
// add to the layers
|
|
1699
|
-
layers[lay].addLayer(polygons[data
|
|
1701
|
+
layers[lay].addLayer(polygons[data["name"]]);
|
|
1700
1702
|
// fly or fit to the bounds if required
|
|
1701
1703
|
if (data.hasOwnProperty("fly") && data.fly === true) {
|
|
1702
|
-
map.flyToBounds(polygons[data
|
|
1704
|
+
map.flyToBounds(polygons[data["name"]].getBounds(),{padding:[50,50]})
|
|
1703
1705
|
}
|
|
1704
1706
|
else if (data.hasOwnProperty("fit") && data.fit === true) {
|
|
1705
|
-
map.fitBounds(polygons[data
|
|
1707
|
+
map.fitBounds(polygons[data["name"]].getBounds(),{padding:[50,50]})
|
|
1706
1708
|
}
|
|
1707
1709
|
}
|
|
1708
1710
|
|
|
@@ -1716,8 +1718,16 @@ function setMarker(data) {
|
|
|
1716
1718
|
delete data.position;
|
|
1717
1719
|
ll = new L.LatLng((data.lat*1), (data.lon*1));
|
|
1718
1720
|
}
|
|
1719
|
-
else if (data.hasOwnProperty("lat") && data.hasOwnProperty("lon")) {
|
|
1720
|
-
|
|
1721
|
+
else if (data.hasOwnProperty("lat") && data.hasOwnProperty("lon")) {
|
|
1722
|
+
if (isNaN(data.lat*1)) { console.log("Invalid lat: lat:",data.lat, " - lon:",data.lon); return; }
|
|
1723
|
+
if (isNaN(data.lon*1)) { console.log("Invalid lon: lat:",data.lat, " - lon:",data.lon); return; }
|
|
1724
|
+
ll = new L.LatLng((data.lat*1), (data.lon*1));
|
|
1725
|
+
}
|
|
1726
|
+
else if (data.hasOwnProperty("latitude") && data.hasOwnProperty("longitude")) {
|
|
1727
|
+
if (isNaN(data.latitude*1)) { console.log("Invalid latitude: lat:",data.latitude, " - lon:",data.longitude); return; }
|
|
1728
|
+
if (isNaN(data.longitude*1)) { console.log("Invalid longitude: lat:",data.latitude, " - lon:",data.longitude); return; }
|
|
1729
|
+
ll = new L.LatLng((data.latitude*1), (data.longitude*1));
|
|
1730
|
+
}
|
|
1721
1731
|
else {
|
|
1722
1732
|
// console.log("No location:",data);
|
|
1723
1733
|
return;
|
|
@@ -1725,7 +1735,7 @@ function setMarker(data) {
|
|
|
1725
1735
|
|
|
1726
1736
|
if (ll.lat === 0 && ll.lng === 0) {
|
|
1727
1737
|
// Add a little wobble so we can zoom into each if required.
|
|
1728
|
-
console.log(data
|
|
1738
|
+
console.log(data["name"],"is at null island.");
|
|
1729
1739
|
ll.lat = Math.round(1000000 * ll.lat + Math.random() * 10000 - 5000) / 1000000;
|
|
1730
1740
|
ll.lng = Math.round(1000000 * ll.lng + Math.random() * 10000 - 5000) / 1000000;
|
|
1731
1741
|
}
|
|
@@ -1749,11 +1759,11 @@ function setMarker(data) {
|
|
|
1749
1759
|
var dir = parseFloat(data.track ?? data.hdg ?? data.heading ?? data.bearing ?? "0") + map.getBearing();
|
|
1750
1760
|
if (data.icon === "ship") {
|
|
1751
1761
|
marker = L.boatMarker(ll, {
|
|
1752
|
-
title: data
|
|
1762
|
+
title: data["name"],
|
|
1753
1763
|
color: (data.iconColor ?? "#5DADE2")
|
|
1754
1764
|
});
|
|
1755
1765
|
marker.setHeading(dir);
|
|
1756
|
-
q = 'https://www.bing.com/images/search?q='+data.icon+'%20%2B"'+encodeURIComponent(data
|
|
1766
|
+
q = 'https://www.bing.com/images/search?q='+data.icon+'%20%2B"'+encodeURIComponent(data["name"])+'"';
|
|
1757
1767
|
words += '<a href=\''+q+'\' target="_thingpic">Pictures</a><br>';
|
|
1758
1768
|
}
|
|
1759
1769
|
else if (data.icon === "plane") {
|
|
@@ -1771,7 +1781,7 @@ function setMarker(data) {
|
|
|
1771
1781
|
iconAnchor: [16, 16],
|
|
1772
1782
|
html:'<img src="'+svgplane+'" style="width:32px; height:32px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>'
|
|
1773
1783
|
});
|
|
1774
|
-
marker = L.marker(ll, {title:data
|
|
1784
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1775
1785
|
}
|
|
1776
1786
|
else if (data.icon === "smallplane") {
|
|
1777
1787
|
data.iconColor = data.iconColor ?? "black";
|
|
@@ -1783,7 +1793,7 @@ function setMarker(data) {
|
|
|
1783
1793
|
iconAnchor: [16, 16],
|
|
1784
1794
|
html:'<img src="'+svgplane+'" style="width:32px; height:32px; -webkit-transform:rotate('+(dir - 45)+'deg); -moz-transform:rotate('+(dir - 45)+'deg);"/>'
|
|
1785
1795
|
});
|
|
1786
|
-
marker = L.marker(ll, {title:data
|
|
1796
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1787
1797
|
}
|
|
1788
1798
|
else if (data.icon === "bus") {
|
|
1789
1799
|
dir = dir - 90;
|
|
@@ -1799,7 +1809,7 @@ function setMarker(data) {
|
|
|
1799
1809
|
iconAnchor: [16, 16],
|
|
1800
1810
|
html:'<img src="'+svgbus+'" style="width:32px; height:32px; -webkit-transform:scaleY('+sc+') rotate('+dir*sc+'deg); -moz-transform:scaleY('+sc+') rotate('+dir*sc+'deg);"/>'
|
|
1801
1811
|
});
|
|
1802
|
-
marker = L.marker(ll, {title:data
|
|
1812
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1803
1813
|
}
|
|
1804
1814
|
else if (data.icon === "helicopter") {
|
|
1805
1815
|
data.iconColor = data.iconColor ?? "black";
|
|
@@ -1816,7 +1826,7 @@ function setMarker(data) {
|
|
|
1816
1826
|
iconAnchor: [16, 16],
|
|
1817
1827
|
html:'<img src="'+svgheli+'" style="width:32px; height:32px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>'
|
|
1818
1828
|
});
|
|
1819
|
-
marker = L.marker(ll, {title:data
|
|
1829
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1820
1830
|
}
|
|
1821
1831
|
else if (data.icon === "uav") {
|
|
1822
1832
|
data.iconColor = data.iconColor || "black";
|
|
@@ -1833,7 +1843,7 @@ function setMarker(data) {
|
|
|
1833
1843
|
iconAnchor: [16, 16],
|
|
1834
1844
|
html:'<img src="'+svguav+'" style="width:32px; height:32px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>',
|
|
1835
1845
|
});
|
|
1836
|
-
marker = L.marker(ll, {title:data
|
|
1846
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1837
1847
|
}
|
|
1838
1848
|
else if (data.icon === "car") {
|
|
1839
1849
|
data.iconColor = data.iconColor || "black";
|
|
@@ -1845,7 +1855,7 @@ function setMarker(data) {
|
|
|
1845
1855
|
iconAnchor: [16, 16],
|
|
1846
1856
|
html:'<img src="'+svgcar+'" style="width:32px; height:32px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>',
|
|
1847
1857
|
});
|
|
1848
|
-
marker = L.marker(ll, {title:data
|
|
1858
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1849
1859
|
}
|
|
1850
1860
|
else if (data.icon === "sensor") {
|
|
1851
1861
|
data.iconColor = data.iconColor || "#F39C12";
|
|
@@ -1856,7 +1866,7 @@ function setMarker(data) {
|
|
|
1856
1866
|
iconAnchor: [12, 12],
|
|
1857
1867
|
html:'<img src="'+svgcam+'" style="width:24px; height:24px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>',
|
|
1858
1868
|
});
|
|
1859
|
-
marker = L.marker(ll, {title:data
|
|
1869
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1860
1870
|
}
|
|
1861
1871
|
else if (data.icon === "arrow") {
|
|
1862
1872
|
data.iconColor = data.iconColor || "black";
|
|
@@ -1868,7 +1878,7 @@ function setMarker(data) {
|
|
|
1868
1878
|
iconAnchor: [16, 16],
|
|
1869
1879
|
html:"'<img src='"+svgarrow+"' style='width:32px; height:32px; -webkit-transform:translate(0px,-16px) rotate("+dir+"deg); -moz-transform:translate(0px,-16px) rotate("+dir+"deg);'/>",
|
|
1870
1880
|
});
|
|
1871
|
-
marker = L.marker(ll, {title:data
|
|
1881
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1872
1882
|
}
|
|
1873
1883
|
else if (data.icon === "wind") {
|
|
1874
1884
|
data.iconColor = data.iconColor || "black";
|
|
@@ -1880,7 +1890,7 @@ function setMarker(data) {
|
|
|
1880
1890
|
iconAnchor: [16, 16],
|
|
1881
1891
|
html:'<img src="'+svgwind+'" style="width:32px; height:32px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>',
|
|
1882
1892
|
});
|
|
1883
|
-
marker = L.marker(ll, {title:data
|
|
1893
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1884
1894
|
}
|
|
1885
1895
|
else if (data.icon === "satellite") {
|
|
1886
1896
|
data.iconColor = data.iconColor || "black";
|
|
@@ -1897,7 +1907,7 @@ function setMarker(data) {
|
|
|
1897
1907
|
iconAnchor: [16, 16],
|
|
1898
1908
|
html:'<img src="'+svgsat+'" style="width:32px; height:32px;"/>',
|
|
1899
1909
|
});
|
|
1900
|
-
marker = L.marker(ll, {title:data
|
|
1910
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1901
1911
|
}
|
|
1902
1912
|
else if ((data.icon === "iss") || (data.icon === "ISS")) {
|
|
1903
1913
|
data.iconColor = data.iconColor || "black";
|
|
@@ -1913,7 +1923,7 @@ function setMarker(data) {
|
|
|
1913
1923
|
iconAnchor: [25, 25],
|
|
1914
1924
|
html:'<img src="'+svgiss+'" style="width:50px; height:50px;"/>',
|
|
1915
1925
|
});
|
|
1916
|
-
marker = L.marker(ll, {title:data
|
|
1926
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1917
1927
|
}
|
|
1918
1928
|
else if (data.icon === "mayflower") {
|
|
1919
1929
|
data.iconColor = data.iconColor || "#910000";
|
|
@@ -1925,7 +1935,7 @@ function setMarker(data) {
|
|
|
1925
1935
|
iconAnchor: [12, 24],
|
|
1926
1936
|
html:'<img src="'+svgmay+'" style="width:24px; height:48px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>',
|
|
1927
1937
|
});
|
|
1928
|
-
marker = L.marker(ll, {title:data
|
|
1938
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1929
1939
|
}
|
|
1930
1940
|
else if (data.icon === "locate") {
|
|
1931
1941
|
data.iconColor = data.iconColor || "#00ffff";
|
|
@@ -1942,26 +1952,26 @@ function setMarker(data) {
|
|
|
1942
1952
|
iconAnchor: [16, 16],
|
|
1943
1953
|
html:'<img src="'+svglocate+'" style="width:32px; height:32px;"/>',
|
|
1944
1954
|
});
|
|
1945
|
-
marker = L.marker(ll, {title:data
|
|
1955
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1946
1956
|
labelOffset = [12,-4];
|
|
1947
1957
|
}
|
|
1948
1958
|
else if (data.icon === "friend") {
|
|
1949
|
-
marker = L.marker(ll, { icon: L.divIcon({ className: 'circle f', iconSize: [20, 12] }), title: data
|
|
1959
|
+
marker = L.marker(ll, { icon: L.divIcon({ className: 'circle f', iconSize: [20, 12] }), title: data["name"], draggable:drag });
|
|
1950
1960
|
}
|
|
1951
1961
|
else if (data.icon === "hostile") {
|
|
1952
|
-
marker = L.marker(ll, { icon: L.divIcon({ className: 'circle h', iconSize: [16, 16] }), title: data
|
|
1962
|
+
marker = L.marker(ll, { icon: L.divIcon({ className: 'circle h', iconSize: [16, 16] }), title: data["name"], draggable:drag });
|
|
1953
1963
|
}
|
|
1954
1964
|
else if (data.icon === "neutral") {
|
|
1955
|
-
marker = L.marker(ll, { icon: L.divIcon({ className: 'circle n', iconSize: [16, 16] }), title: data
|
|
1965
|
+
marker = L.marker(ll, { icon: L.divIcon({ className: 'circle n', iconSize: [16, 16] }), title: data["name"], draggable:drag });
|
|
1956
1966
|
}
|
|
1957
1967
|
else if (data.icon === "unknown") {
|
|
1958
|
-
marker = L.marker(ll, { icon: L.divIcon({ className: 'circle', iconSize: [16, 16] }), title: data
|
|
1968
|
+
marker = L.marker(ll, { icon: L.divIcon({ className: 'circle', iconSize: [16, 16] }), title: data["name"], draggable:drag });
|
|
1959
1969
|
}
|
|
1960
1970
|
else if (data.icon === "danger") {
|
|
1961
|
-
marker = L.marker(ll, { icon: L.divIcon({ className: 'up-triangle' }), title: data
|
|
1971
|
+
marker = L.marker(ll, { icon: L.divIcon({ className: 'up-triangle' }), title: data["name"], draggable:drag });
|
|
1962
1972
|
}
|
|
1963
1973
|
else if (data.icon === "earthquake") {
|
|
1964
|
-
marker = L.marker(ll, { icon: L.divIcon({ className: 'circle e', iconSize: [data.mag*5, data.mag*5] }), title: data
|
|
1974
|
+
marker = L.marker(ll, { icon: L.divIcon({ className: 'circle e', iconSize: [data.mag*5, data.mag*5] }), title: data["name"], draggable:drag });
|
|
1965
1975
|
}
|
|
1966
1976
|
else if (data.icon.match(/^:.*:$/g)) { // emoji icon :smile:
|
|
1967
1977
|
var em = emojify(data.icon);
|
|
@@ -1971,7 +1981,7 @@ function setMarker(data) {
|
|
|
1971
1981
|
html: '<center><span style="font-size:2em; color:'+col+'">'+em+'</span></center>',
|
|
1972
1982
|
iconSize: [32, 32]
|
|
1973
1983
|
});
|
|
1974
|
-
marker = L.marker(ll, {title:data
|
|
1984
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1975
1985
|
labelOffset = [12,-4];
|
|
1976
1986
|
}
|
|
1977
1987
|
else if (data.icon.match(/^https?:.*$|^\/|^data:image\//)) { // web url icon https://...
|
|
@@ -1982,7 +1992,7 @@ function setMarker(data) {
|
|
|
1982
1992
|
iconAnchor: [sz/2, sz/2],
|
|
1983
1993
|
popupAnchor: [0, -sz/2]
|
|
1984
1994
|
});
|
|
1985
|
-
marker = L.marker(ll, {title:data
|
|
1995
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag, rotationAngle:dir, rotationOrigin:"center"});
|
|
1986
1996
|
labelOffset = [sz/2-4,-4];
|
|
1987
1997
|
delete data.iconSize;
|
|
1988
1998
|
}
|
|
@@ -1997,7 +2007,7 @@ function setMarker(data) {
|
|
|
1997
2007
|
iconAnchor: [16, 12],
|
|
1998
2008
|
popupAnchor: [0, -16]
|
|
1999
2009
|
});
|
|
2000
|
-
marker = L.marker(ll, {title:data
|
|
2010
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
2001
2011
|
labelOffset = [8,-8];
|
|
2002
2012
|
}
|
|
2003
2013
|
else if (data.icon.substr(0,3) === "wi-") { // weather icon
|
|
@@ -2011,7 +2021,7 @@ function setMarker(data) {
|
|
|
2011
2021
|
iconAnchor: [16, 16],
|
|
2012
2022
|
popupAnchor: [0, -16]
|
|
2013
2023
|
});
|
|
2014
|
-
marker = L.marker(ll, {title:data
|
|
2024
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
2015
2025
|
labelOffset = [16,-16];
|
|
2016
2026
|
}
|
|
2017
2027
|
else {
|
|
@@ -2021,13 +2031,13 @@ function setMarker(data) {
|
|
|
2021
2031
|
prefix: 'fa',
|
|
2022
2032
|
iconColor: 'white'
|
|
2023
2033
|
});
|
|
2024
|
-
marker = L.marker(ll, {title:data
|
|
2034
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
2025
2035
|
labelOffset = [6,-6];
|
|
2026
2036
|
}
|
|
2027
2037
|
}
|
|
2028
2038
|
else if (data.hasOwnProperty("SIDC")) { // NATO mil2525 icons
|
|
2029
2039
|
// "SIDC":"SFGPU------E***","name":"1.C2 komp","fullname":"1.C2 komp/FTS/INSS"
|
|
2030
|
-
myMarker = new ms.Symbol( data.SIDC.toUpperCase(), { uniqueDesignation:unescape(encodeURIComponent(data
|
|
2040
|
+
myMarker = new ms.Symbol( data.SIDC.toUpperCase(), { uniqueDesignation:unescape(encodeURIComponent(data["name"])) });
|
|
2031
2041
|
// Now that we have a symbol we can ask for the echelon and set the symbol size
|
|
2032
2042
|
var opts = data.options || {};
|
|
2033
2043
|
var sz = 25;
|
|
@@ -2051,7 +2061,7 @@ function setMarker(data) {
|
|
|
2051
2061
|
iconAnchor: [myMarker.getAnchor().x, myMarker.getAnchor().y],
|
|
2052
2062
|
className: "natoicon",
|
|
2053
2063
|
});
|
|
2054
|
-
marker = L.marker(ll, { title:data
|
|
2064
|
+
marker = L.marker(ll, { title:data["name"], icon:myicon, draggable:drag });
|
|
2055
2065
|
edgeAware();
|
|
2056
2066
|
delete data.options;
|
|
2057
2067
|
}
|
|
@@ -2062,10 +2072,10 @@ function setMarker(data) {
|
|
|
2062
2072
|
prefix: 'fa',
|
|
2063
2073
|
iconColor: 'white'
|
|
2064
2074
|
});
|
|
2065
|
-
marker = L.marker(ll, {title:data
|
|
2075
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
2066
2076
|
labelOffset = [6,-6];
|
|
2067
2077
|
}
|
|
2068
|
-
marker.name = data
|
|
2078
|
+
marker.name = data["name"];
|
|
2069
2079
|
|
|
2070
2080
|
// var createLabelIcon = function(labelText) {
|
|
2071
2081
|
// return L.marker(new L.LatLng(51.05, -1.35), {icon:L.divIcon({ html:labelText })});
|
|
@@ -2128,6 +2138,7 @@ function setMarker(data) {
|
|
|
2128
2138
|
// remove items from list of properties, then add all others to popup
|
|
2129
2139
|
if (data.hasOwnProperty("options")) { delete data.options; }
|
|
2130
2140
|
if (data.hasOwnProperty("icon")) { delete data.icon; }
|
|
2141
|
+
if (data.hasOwnProperty("iconSize")) { delete data.iconSize; }
|
|
2131
2142
|
if (data.hasOwnProperty("iconColor")) { delete data.iconColor; }
|
|
2132
2143
|
if (data.hasOwnProperty("photourl")) {
|
|
2133
2144
|
words += "<img src=\"" + data.photourl + "\" style=\"max-width:100%; max-height:250px; margin-top:10px;\"><br/>";
|
|
@@ -2186,7 +2197,7 @@ function setMarker(data) {
|
|
|
2186
2197
|
// If .label then use that rather than name tooltip
|
|
2187
2198
|
if (data.label) {
|
|
2188
2199
|
if (typeof data.label === "boolean" && data.label === true) {
|
|
2189
|
-
marker.bindTooltip(data
|
|
2200
|
+
marker.bindTooltip(data["name"], { permanent:true, direction:"right", offset:labelOffset });
|
|
2190
2201
|
}
|
|
2191
2202
|
else if (typeof data.label === "string" && data.label.length > 0) {
|
|
2192
2203
|
marker.bindTooltip(data.label, { permanent:true, direction:"right", offset:labelOffset });
|
|
@@ -2244,12 +2255,12 @@ function setMarker(data) {
|
|
|
2244
2255
|
words += '<tr><td>lat, lon</td><td>'+ marker.getLatLng().toString().replace('LatLng(','').replace(')','') + '</td></tr>';
|
|
2245
2256
|
words += '</table>';
|
|
2246
2257
|
}
|
|
2247
|
-
words = "<b>"+data
|
|
2258
|
+
words = "<b>"+data["name"]+"</b><br/>" + words.replace(/\${name}/g,data["name"]); //"<button style=\"border-radius:4px; float:right; background-color:lightgrey;\" onclick='popped=false;popmark.closePopup();'>X</button><br/>" + words;
|
|
2248
2259
|
var wopt = {autoClose:false, closeButton:true, closeOnClick:false, minWidth:200};
|
|
2249
2260
|
if (words.indexOf('<video ') >=0 || words.indexOf('<img ') >=0 ) { wopt.maxWidth="640"; } // make popup wider if it has an image or video
|
|
2250
2261
|
if (!data.hasOwnProperty("clickable") && data.clickable != false) {
|
|
2251
2262
|
marker.bindPopup(words, wopt);
|
|
2252
|
-
marker._popup.dname = data
|
|
2263
|
+
marker._popup.dname = data["name"];
|
|
2253
2264
|
}
|
|
2254
2265
|
marker.lay = lay; // and the layer it is on
|
|
2255
2266
|
|
|
@@ -2262,7 +2273,7 @@ function setMarker(data) {
|
|
|
2262
2273
|
if (heat && ((data.addtoheatmap != false) || (!data.hasOwnProperty("addtoheatmap")))) { // Added to give ability to control if points from active layer contribute to heatmap
|
|
2263
2274
|
if (heatAll || map.hasLayer(layers[lay])) { heat.addLatLng(lli); }
|
|
2264
2275
|
}
|
|
2265
|
-
markers[data
|
|
2276
|
+
markers[data["name"]] = marker;
|
|
2266
2277
|
layers[lay].addLayer(marker);
|
|
2267
2278
|
|
|
2268
2279
|
// var track;
|
|
@@ -2285,11 +2296,11 @@ function setMarker(data) {
|
|
|
2285
2296
|
else if ( re3.test(""+data.speed) ) { data.length = data.length * 0.44704; }
|
|
2286
2297
|
}
|
|
2287
2298
|
if (data.length !== undefined) {
|
|
2288
|
-
if (polygons[data
|
|
2289
|
-
map.removeLayer(polygons[data
|
|
2299
|
+
if (polygons[data["name"]] != null && !polygons[data["name"]].hasOwnProperty("_layers")) {
|
|
2300
|
+
map.removeLayer(polygons[data["name"]]);
|
|
2290
2301
|
}
|
|
2291
|
-
if (polygons[data
|
|
2292
|
-
delete(layers[lay]._layers[polygons[data
|
|
2302
|
+
if (polygons[data["name"]] != null && polygons[data["name"]].hasOwnProperty("name") ) {
|
|
2303
|
+
delete(layers[lay]._layers[polygons[data["name"]]._leaflet_id]);
|
|
2293
2304
|
}
|
|
2294
2305
|
var x = ll.lng * 1; // X coordinate
|
|
2295
2306
|
var y = ll.lat * 1; // Y coordinate
|
|
@@ -2319,14 +2330,14 @@ function setMarker(data) {
|
|
|
2319
2330
|
polygon.setStyle({opacity:0});
|
|
2320
2331
|
}
|
|
2321
2332
|
}
|
|
2322
|
-
polygon.name = data
|
|
2323
|
-
if (polygons[data
|
|
2324
|
-
polygons[data
|
|
2333
|
+
polygon.name = data["name"];
|
|
2334
|
+
if (polygons[data["name"]] != null && polygons[data["name"]].hasOwnProperty("_layers")) {
|
|
2335
|
+
polygons[data["name"]].addLayer(polygon);
|
|
2325
2336
|
}
|
|
2326
2337
|
else {
|
|
2327
|
-
polygons[data
|
|
2338
|
+
polygons[data["name"]] = polygon;
|
|
2328
2339
|
}
|
|
2329
|
-
polygons[data
|
|
2340
|
+
polygons[data["name"]].lay = lay;
|
|
2330
2341
|
layers[lay].addLayer(polygon);
|
|
2331
2342
|
}
|
|
2332
2343
|
}
|
|
@@ -3143,7 +3154,9 @@ function doGeojson(n,g,l,o) { // name, geojson, layer, options
|
|
|
3143
3154
|
delete tx["name"];
|
|
3144
3155
|
tx = JSON.stringify(tx,null,' ');
|
|
3145
3156
|
if ( tx !== "{}") {
|
|
3146
|
-
|
|
3157
|
+
var gp = '<pre style="overflow-x:scroll">'+tx.replace(/[\{\}"]/g,'')+'</pre>'
|
|
3158
|
+
if (n) { gp = '<b>'+n+'</b>' + gp; }
|
|
3159
|
+
l.bindPopup(gp);
|
|
3147
3160
|
}
|
|
3148
3161
|
}
|
|
3149
3162
|
if (o && o.hasOwnProperty("clickable") && o.clickable === true) {
|