node-red-contrib-web-worldmap 4.3.2 → 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 +1 -0
- package/README.md +1 -0
- package/package.json +1 -1
- package/worldmap/worldmap.js +81 -79
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Feel free to [ {
|
|
|
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
|
|
|
@@ -1733,7 +1735,7 @@ function setMarker(data) {
|
|
|
1733
1735
|
|
|
1734
1736
|
if (ll.lat === 0 && ll.lng === 0) {
|
|
1735
1737
|
// Add a little wobble so we can zoom into each if required.
|
|
1736
|
-
console.log(data
|
|
1738
|
+
console.log(data["name"],"is at null island.");
|
|
1737
1739
|
ll.lat = Math.round(1000000 * ll.lat + Math.random() * 10000 - 5000) / 1000000;
|
|
1738
1740
|
ll.lng = Math.round(1000000 * ll.lng + Math.random() * 10000 - 5000) / 1000000;
|
|
1739
1741
|
}
|
|
@@ -1757,11 +1759,11 @@ function setMarker(data) {
|
|
|
1757
1759
|
var dir = parseFloat(data.track ?? data.hdg ?? data.heading ?? data.bearing ?? "0") + map.getBearing();
|
|
1758
1760
|
if (data.icon === "ship") {
|
|
1759
1761
|
marker = L.boatMarker(ll, {
|
|
1760
|
-
title: data
|
|
1762
|
+
title: data["name"],
|
|
1761
1763
|
color: (data.iconColor ?? "#5DADE2")
|
|
1762
1764
|
});
|
|
1763
1765
|
marker.setHeading(dir);
|
|
1764
|
-
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"])+'"';
|
|
1765
1767
|
words += '<a href=\''+q+'\' target="_thingpic">Pictures</a><br>';
|
|
1766
1768
|
}
|
|
1767
1769
|
else if (data.icon === "plane") {
|
|
@@ -1779,7 +1781,7 @@ function setMarker(data) {
|
|
|
1779
1781
|
iconAnchor: [16, 16],
|
|
1780
1782
|
html:'<img src="'+svgplane+'" style="width:32px; height:32px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>'
|
|
1781
1783
|
});
|
|
1782
|
-
marker = L.marker(ll, {title:data
|
|
1784
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1783
1785
|
}
|
|
1784
1786
|
else if (data.icon === "smallplane") {
|
|
1785
1787
|
data.iconColor = data.iconColor ?? "black";
|
|
@@ -1791,7 +1793,7 @@ function setMarker(data) {
|
|
|
1791
1793
|
iconAnchor: [16, 16],
|
|
1792
1794
|
html:'<img src="'+svgplane+'" style="width:32px; height:32px; -webkit-transform:rotate('+(dir - 45)+'deg); -moz-transform:rotate('+(dir - 45)+'deg);"/>'
|
|
1793
1795
|
});
|
|
1794
|
-
marker = L.marker(ll, {title:data
|
|
1796
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1795
1797
|
}
|
|
1796
1798
|
else if (data.icon === "bus") {
|
|
1797
1799
|
dir = dir - 90;
|
|
@@ -1807,7 +1809,7 @@ function setMarker(data) {
|
|
|
1807
1809
|
iconAnchor: [16, 16],
|
|
1808
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);"/>'
|
|
1809
1811
|
});
|
|
1810
|
-
marker = L.marker(ll, {title:data
|
|
1812
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1811
1813
|
}
|
|
1812
1814
|
else if (data.icon === "helicopter") {
|
|
1813
1815
|
data.iconColor = data.iconColor ?? "black";
|
|
@@ -1824,7 +1826,7 @@ function setMarker(data) {
|
|
|
1824
1826
|
iconAnchor: [16, 16],
|
|
1825
1827
|
html:'<img src="'+svgheli+'" style="width:32px; height:32px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>'
|
|
1826
1828
|
});
|
|
1827
|
-
marker = L.marker(ll, {title:data
|
|
1829
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1828
1830
|
}
|
|
1829
1831
|
else if (data.icon === "uav") {
|
|
1830
1832
|
data.iconColor = data.iconColor || "black";
|
|
@@ -1841,7 +1843,7 @@ function setMarker(data) {
|
|
|
1841
1843
|
iconAnchor: [16, 16],
|
|
1842
1844
|
html:'<img src="'+svguav+'" style="width:32px; height:32px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>',
|
|
1843
1845
|
});
|
|
1844
|
-
marker = L.marker(ll, {title:data
|
|
1846
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1845
1847
|
}
|
|
1846
1848
|
else if (data.icon === "car") {
|
|
1847
1849
|
data.iconColor = data.iconColor || "black";
|
|
@@ -1853,7 +1855,7 @@ function setMarker(data) {
|
|
|
1853
1855
|
iconAnchor: [16, 16],
|
|
1854
1856
|
html:'<img src="'+svgcar+'" style="width:32px; height:32px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>',
|
|
1855
1857
|
});
|
|
1856
|
-
marker = L.marker(ll, {title:data
|
|
1858
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1857
1859
|
}
|
|
1858
1860
|
else if (data.icon === "sensor") {
|
|
1859
1861
|
data.iconColor = data.iconColor || "#F39C12";
|
|
@@ -1864,7 +1866,7 @@ function setMarker(data) {
|
|
|
1864
1866
|
iconAnchor: [12, 12],
|
|
1865
1867
|
html:'<img src="'+svgcam+'" style="width:24px; height:24px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>',
|
|
1866
1868
|
});
|
|
1867
|
-
marker = L.marker(ll, {title:data
|
|
1869
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1868
1870
|
}
|
|
1869
1871
|
else if (data.icon === "arrow") {
|
|
1870
1872
|
data.iconColor = data.iconColor || "black";
|
|
@@ -1876,7 +1878,7 @@ function setMarker(data) {
|
|
|
1876
1878
|
iconAnchor: [16, 16],
|
|
1877
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);'/>",
|
|
1878
1880
|
});
|
|
1879
|
-
marker = L.marker(ll, {title:data
|
|
1881
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1880
1882
|
}
|
|
1881
1883
|
else if (data.icon === "wind") {
|
|
1882
1884
|
data.iconColor = data.iconColor || "black";
|
|
@@ -1888,7 +1890,7 @@ function setMarker(data) {
|
|
|
1888
1890
|
iconAnchor: [16, 16],
|
|
1889
1891
|
html:'<img src="'+svgwind+'" style="width:32px; height:32px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>',
|
|
1890
1892
|
});
|
|
1891
|
-
marker = L.marker(ll, {title:data
|
|
1893
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1892
1894
|
}
|
|
1893
1895
|
else if (data.icon === "satellite") {
|
|
1894
1896
|
data.iconColor = data.iconColor || "black";
|
|
@@ -1905,7 +1907,7 @@ function setMarker(data) {
|
|
|
1905
1907
|
iconAnchor: [16, 16],
|
|
1906
1908
|
html:'<img src="'+svgsat+'" style="width:32px; height:32px;"/>',
|
|
1907
1909
|
});
|
|
1908
|
-
marker = L.marker(ll, {title:data
|
|
1910
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1909
1911
|
}
|
|
1910
1912
|
else if ((data.icon === "iss") || (data.icon === "ISS")) {
|
|
1911
1913
|
data.iconColor = data.iconColor || "black";
|
|
@@ -1921,7 +1923,7 @@ function setMarker(data) {
|
|
|
1921
1923
|
iconAnchor: [25, 25],
|
|
1922
1924
|
html:'<img src="'+svgiss+'" style="width:50px; height:50px;"/>',
|
|
1923
1925
|
});
|
|
1924
|
-
marker = L.marker(ll, {title:data
|
|
1926
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1925
1927
|
}
|
|
1926
1928
|
else if (data.icon === "mayflower") {
|
|
1927
1929
|
data.iconColor = data.iconColor || "#910000";
|
|
@@ -1933,7 +1935,7 @@ function setMarker(data) {
|
|
|
1933
1935
|
iconAnchor: [12, 24],
|
|
1934
1936
|
html:'<img src="'+svgmay+'" style="width:24px; height:48px; -webkit-transform:rotate('+dir+'deg); -moz-transform:rotate('+dir+'deg);"/>',
|
|
1935
1937
|
});
|
|
1936
|
-
marker = L.marker(ll, {title:data
|
|
1938
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1937
1939
|
}
|
|
1938
1940
|
else if (data.icon === "locate") {
|
|
1939
1941
|
data.iconColor = data.iconColor || "#00ffff";
|
|
@@ -1950,26 +1952,26 @@ function setMarker(data) {
|
|
|
1950
1952
|
iconAnchor: [16, 16],
|
|
1951
1953
|
html:'<img src="'+svglocate+'" style="width:32px; height:32px;"/>',
|
|
1952
1954
|
});
|
|
1953
|
-
marker = L.marker(ll, {title:data
|
|
1955
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1954
1956
|
labelOffset = [12,-4];
|
|
1955
1957
|
}
|
|
1956
1958
|
else if (data.icon === "friend") {
|
|
1957
|
-
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 });
|
|
1958
1960
|
}
|
|
1959
1961
|
else if (data.icon === "hostile") {
|
|
1960
|
-
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 });
|
|
1961
1963
|
}
|
|
1962
1964
|
else if (data.icon === "neutral") {
|
|
1963
|
-
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 });
|
|
1964
1966
|
}
|
|
1965
1967
|
else if (data.icon === "unknown") {
|
|
1966
|
-
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 });
|
|
1967
1969
|
}
|
|
1968
1970
|
else if (data.icon === "danger") {
|
|
1969
|
-
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 });
|
|
1970
1972
|
}
|
|
1971
1973
|
else if (data.icon === "earthquake") {
|
|
1972
|
-
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 });
|
|
1973
1975
|
}
|
|
1974
1976
|
else if (data.icon.match(/^:.*:$/g)) { // emoji icon :smile:
|
|
1975
1977
|
var em = emojify(data.icon);
|
|
@@ -1979,7 +1981,7 @@ function setMarker(data) {
|
|
|
1979
1981
|
html: '<center><span style="font-size:2em; color:'+col+'">'+em+'</span></center>',
|
|
1980
1982
|
iconSize: [32, 32]
|
|
1981
1983
|
});
|
|
1982
|
-
marker = L.marker(ll, {title:data
|
|
1984
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
1983
1985
|
labelOffset = [12,-4];
|
|
1984
1986
|
}
|
|
1985
1987
|
else if (data.icon.match(/^https?:.*$|^\/|^data:image\//)) { // web url icon https://...
|
|
@@ -1990,7 +1992,7 @@ function setMarker(data) {
|
|
|
1990
1992
|
iconAnchor: [sz/2, sz/2],
|
|
1991
1993
|
popupAnchor: [0, -sz/2]
|
|
1992
1994
|
});
|
|
1993
|
-
marker = L.marker(ll, {title:data
|
|
1995
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag, rotationAngle:dir, rotationOrigin:"center"});
|
|
1994
1996
|
labelOffset = [sz/2-4,-4];
|
|
1995
1997
|
delete data.iconSize;
|
|
1996
1998
|
}
|
|
@@ -2005,7 +2007,7 @@ function setMarker(data) {
|
|
|
2005
2007
|
iconAnchor: [16, 12],
|
|
2006
2008
|
popupAnchor: [0, -16]
|
|
2007
2009
|
});
|
|
2008
|
-
marker = L.marker(ll, {title:data
|
|
2010
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
2009
2011
|
labelOffset = [8,-8];
|
|
2010
2012
|
}
|
|
2011
2013
|
else if (data.icon.substr(0,3) === "wi-") { // weather icon
|
|
@@ -2019,7 +2021,7 @@ function setMarker(data) {
|
|
|
2019
2021
|
iconAnchor: [16, 16],
|
|
2020
2022
|
popupAnchor: [0, -16]
|
|
2021
2023
|
});
|
|
2022
|
-
marker = L.marker(ll, {title:data
|
|
2024
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
2023
2025
|
labelOffset = [16,-16];
|
|
2024
2026
|
}
|
|
2025
2027
|
else {
|
|
@@ -2029,13 +2031,13 @@ function setMarker(data) {
|
|
|
2029
2031
|
prefix: 'fa',
|
|
2030
2032
|
iconColor: 'white'
|
|
2031
2033
|
});
|
|
2032
|
-
marker = L.marker(ll, {title:data
|
|
2034
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
2033
2035
|
labelOffset = [6,-6];
|
|
2034
2036
|
}
|
|
2035
2037
|
}
|
|
2036
2038
|
else if (data.hasOwnProperty("SIDC")) { // NATO mil2525 icons
|
|
2037
2039
|
// "SIDC":"SFGPU------E***","name":"1.C2 komp","fullname":"1.C2 komp/FTS/INSS"
|
|
2038
|
-
myMarker = new ms.Symbol( data.SIDC.toUpperCase(), { uniqueDesignation:unescape(encodeURIComponent(data
|
|
2040
|
+
myMarker = new ms.Symbol( data.SIDC.toUpperCase(), { uniqueDesignation:unescape(encodeURIComponent(data["name"])) });
|
|
2039
2041
|
// Now that we have a symbol we can ask for the echelon and set the symbol size
|
|
2040
2042
|
var opts = data.options || {};
|
|
2041
2043
|
var sz = 25;
|
|
@@ -2059,7 +2061,7 @@ function setMarker(data) {
|
|
|
2059
2061
|
iconAnchor: [myMarker.getAnchor().x, myMarker.getAnchor().y],
|
|
2060
2062
|
className: "natoicon",
|
|
2061
2063
|
});
|
|
2062
|
-
marker = L.marker(ll, { title:data
|
|
2064
|
+
marker = L.marker(ll, { title:data["name"], icon:myicon, draggable:drag });
|
|
2063
2065
|
edgeAware();
|
|
2064
2066
|
delete data.options;
|
|
2065
2067
|
}
|
|
@@ -2070,10 +2072,10 @@ function setMarker(data) {
|
|
|
2070
2072
|
prefix: 'fa',
|
|
2071
2073
|
iconColor: 'white'
|
|
2072
2074
|
});
|
|
2073
|
-
marker = L.marker(ll, {title:data
|
|
2075
|
+
marker = L.marker(ll, {title:data["name"], icon:myMarker, draggable:drag});
|
|
2074
2076
|
labelOffset = [6,-6];
|
|
2075
2077
|
}
|
|
2076
|
-
marker.name = data
|
|
2078
|
+
marker.name = data["name"];
|
|
2077
2079
|
|
|
2078
2080
|
// var createLabelIcon = function(labelText) {
|
|
2079
2081
|
// return L.marker(new L.LatLng(51.05, -1.35), {icon:L.divIcon({ html:labelText })});
|
|
@@ -2195,7 +2197,7 @@ function setMarker(data) {
|
|
|
2195
2197
|
// If .label then use that rather than name tooltip
|
|
2196
2198
|
if (data.label) {
|
|
2197
2199
|
if (typeof data.label === "boolean" && data.label === true) {
|
|
2198
|
-
marker.bindTooltip(data
|
|
2200
|
+
marker.bindTooltip(data["name"], { permanent:true, direction:"right", offset:labelOffset });
|
|
2199
2201
|
}
|
|
2200
2202
|
else if (typeof data.label === "string" && data.label.length > 0) {
|
|
2201
2203
|
marker.bindTooltip(data.label, { permanent:true, direction:"right", offset:labelOffset });
|
|
@@ -2253,12 +2255,12 @@ function setMarker(data) {
|
|
|
2253
2255
|
words += '<tr><td>lat, lon</td><td>'+ marker.getLatLng().toString().replace('LatLng(','').replace(')','') + '</td></tr>';
|
|
2254
2256
|
words += '</table>';
|
|
2255
2257
|
}
|
|
2256
|
-
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;
|
|
2257
2259
|
var wopt = {autoClose:false, closeButton:true, closeOnClick:false, minWidth:200};
|
|
2258
2260
|
if (words.indexOf('<video ') >=0 || words.indexOf('<img ') >=0 ) { wopt.maxWidth="640"; } // make popup wider if it has an image or video
|
|
2259
2261
|
if (!data.hasOwnProperty("clickable") && data.clickable != false) {
|
|
2260
2262
|
marker.bindPopup(words, wopt);
|
|
2261
|
-
marker._popup.dname = data
|
|
2263
|
+
marker._popup.dname = data["name"];
|
|
2262
2264
|
}
|
|
2263
2265
|
marker.lay = lay; // and the layer it is on
|
|
2264
2266
|
|
|
@@ -2271,7 +2273,7 @@ function setMarker(data) {
|
|
|
2271
2273
|
if (heat && ((data.addtoheatmap != false) || (!data.hasOwnProperty("addtoheatmap")))) { // Added to give ability to control if points from active layer contribute to heatmap
|
|
2272
2274
|
if (heatAll || map.hasLayer(layers[lay])) { heat.addLatLng(lli); }
|
|
2273
2275
|
}
|
|
2274
|
-
markers[data
|
|
2276
|
+
markers[data["name"]] = marker;
|
|
2275
2277
|
layers[lay].addLayer(marker);
|
|
2276
2278
|
|
|
2277
2279
|
// var track;
|
|
@@ -2294,11 +2296,11 @@ function setMarker(data) {
|
|
|
2294
2296
|
else if ( re3.test(""+data.speed) ) { data.length = data.length * 0.44704; }
|
|
2295
2297
|
}
|
|
2296
2298
|
if (data.length !== undefined) {
|
|
2297
|
-
if (polygons[data
|
|
2298
|
-
map.removeLayer(polygons[data
|
|
2299
|
+
if (polygons[data["name"]] != null && !polygons[data["name"]].hasOwnProperty("_layers")) {
|
|
2300
|
+
map.removeLayer(polygons[data["name"]]);
|
|
2299
2301
|
}
|
|
2300
|
-
if (polygons[data
|
|
2301
|
-
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]);
|
|
2302
2304
|
}
|
|
2303
2305
|
var x = ll.lng * 1; // X coordinate
|
|
2304
2306
|
var y = ll.lat * 1; // Y coordinate
|
|
@@ -2328,14 +2330,14 @@ function setMarker(data) {
|
|
|
2328
2330
|
polygon.setStyle({opacity:0});
|
|
2329
2331
|
}
|
|
2330
2332
|
}
|
|
2331
|
-
polygon.name = data
|
|
2332
|
-
if (polygons[data
|
|
2333
|
-
polygons[data
|
|
2333
|
+
polygon.name = data["name"];
|
|
2334
|
+
if (polygons[data["name"]] != null && polygons[data["name"]].hasOwnProperty("_layers")) {
|
|
2335
|
+
polygons[data["name"]].addLayer(polygon);
|
|
2334
2336
|
}
|
|
2335
2337
|
else {
|
|
2336
|
-
polygons[data
|
|
2338
|
+
polygons[data["name"]] = polygon;
|
|
2337
2339
|
}
|
|
2338
|
-
polygons[data
|
|
2340
|
+
polygons[data["name"]].lay = lay;
|
|
2339
2341
|
layers[lay].addLayer(polygon);
|
|
2340
2342
|
}
|
|
2341
2343
|
}
|