Fixup more kml markup and geojson drag drop

This commit is contained in:
Dave Conway-Jones 2023-08-26 18:00:56 +01:00
parent d3259b7189
commit 21e56f9afb
No known key found for this signature in database
GPG Key ID: 1DDB0E91A28C2643
5 changed files with 37 additions and 10 deletions

View File

@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap
- v2.42.2 - More KML and GEOJson drag drop fixes
- v2.42.1 - Remove extraneous debug logging, fix KMZ icons
- v2.42.0 - Add handling for TAK type spots, waypoints, alerts, sensors. Better KML/KMZ handling.
- v2.41.0 - Bump leaflet libs to latest stable (1.9.4)

View File

@ -13,6 +13,7 @@ Feel free to [![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%
### Updates
- v2.42.2 - More KML and GEOJson drag drop fixes
- v2.42.1 - Remove extraneous debug logging, fix KMZ icons
- v2.42.0 - Add handling for TAK type spots, waypoints, alerts, sensors. Better KML/KMZ handling.
- v2.41.0 - Bump leaflet libs to latest stable (1.9.4)

View File

@ -1,6 +1,6 @@
{
"name": "node-red-contrib-web-worldmap",
"version": "2.42.1",
"version": "2.42.2",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": {
"@turf/bezier-spline": "~6.5.0",

View File

@ -140,6 +140,9 @@
text = new TextDecoder(encoding[1]).decode(data);
}
}
else {
text = text.substr(text.indexOf('<'));
}
return text ? (new DOMParser()).parseFromString(text, 'text/xml') : document.implementation.createDocument(null, "kml");}
function unzip(folder) {
@ -265,6 +268,7 @@
// TODO: handle L.svg renderer within the L.KMZMarker class?
},
style: (feature) => {
// console.log("FEATSTYLE",feature)
var styles = {};
var prop = feature.properties;
@ -289,16 +293,18 @@
return styles;
},
onEachFeature: (feature, layer) => {
if (!this.options.ballon) return;
// console.log("POP",feature.properties)
//if (!this.options.ballon) return;
var prop = feature.properties;
var name = prop.name || "";
var desc = prop.description || "";
var name = (prop.name || "").trim();
var desc = (prop.description || "").trim();
var p = '<div>';
if (name || desc) {
if (this.options.bindPopup) {
layer.bindPopup('<div>' + '<b>' + name + '</b>' + '<br>' + desc + '</div>');
}
// if (this.options.bindPopup) {
// p += '<b>' + name + '</b>' + '<br>' + desc + '</div>';
// }
if (this.options.bindTooltip) {
layer.bindTooltip('<b>' + name + '</b>', {
direction: 'auto',
@ -306,6 +312,22 @@
});
}
}
var u = {};
if (prop.FeaturePlatformId) { u.FeaturePlatformId = prop.FeaturePlatformId; }
if (prop.FeatureAddress) { u.FeatureAddress = prop.FeatureAddress; }
if (prop.SymbolSpecification) { u.Symbol = prop.SymbolSpecification; }
if (prop.Speed) { u.Speed = prop.Speed; }
if (prop.FeatureLastModified) { u.LastUpdate = prop.FeatureLastModified; }
if (u.LastUpdate) { u.LastUpdate = (new Date(u.LastUpdate*1000)).toISOString(); }
Object.entries(u).forEach(([key, value]) => {
p += '<b>'+key+'</b> : '+value+'<br/>';
});
p += '</div>';
if (p !== '<div></div>') {
layer.bindPopup(p);
}
},
interactive: this.options.interactive,
});
@ -426,5 +448,4 @@
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=leaflet-kmz-src.js.map
})));

View File

@ -257,6 +257,10 @@ var readFile = function(file) {
console.log("ZIP FILE",file);
}
}
else if (file.type.indexOf('geo+json') !== -1 ) {
data = JSON.parse(data);
doGeojson(file.name,data,"geojson");
}
else {
try {
data = JSON.parse(data);
@ -2874,7 +2878,7 @@ function doCommand(cmd) {
// handle any incoming GEOJSON directly - may style badly
function doGeojson(n,g,l,o) {
// console.log("GEOJSON",n,g,l,o)
// console.log("GEOJSON",n,g,l,o) // name,geojson,layer,options
var lay = l ?? g.name ?? "unknown";
// if (!basemaps[lay]) {
var opt = { style: function(feature) {