Live updating Worldmap with kml data

I am currently using the worldmap node to plot lots of different things. No problem there.
I read the two forum posts that mention .kml files and am not sure they cover my required use case.

I have a URL that is written by a Windows application, it updates a .kml file every 1-2 minutes.
The URL is actually on an FTP server under my control.
I can use Google Earth and point it at the URL of the .kml file and set the auto update rate and it works great, but I don't want to have to use Google Earth when I already have my data on the worldmap... I want to add this new data stream to the same map as a new layer.

Worldmap hints at some sort of file drop function, but I don't want to have to have my users manually download and drop the .kml file on their map.

Is there a way to live stream/update worldmap with my .kml data?
@dceejay Any thoughts?

Thanks.

You can add kml as an overlay - like GitHub - dceejay/RedMap: A web map app for Node-RED to put blobs on

Could use just a little bit more of a nudge in the right direction here....

My function node has pretty much a cut copy from the link you mentioned.

msg.payload.command.map = {
    "overlay": "PC-HFDL-SDR1",
    "kml": "<kml>"+msg.payload+"</kml>"
};
return msg;

The link seems to state (by my reading);

a kml property containing the KML string

I have the msg.payload out of the http get node as a .kml string, so what am I missing?

Also I am not sure why msg.payload.command.map is undefined.

Your payload is a string not an object so it can't have a .command property

As kml is XML, pass it through an XML node then you can access properties like any other js object.

Thanks for the tip @Steve-Mcl I walked the entire tree with the function node, and always the same error.
Here is the flow now.


Here is the object after the xml node.

image

The error is the same.

msg.payload.command.map = {
    "overlay": "PC-HFDL-SDR1",
    "kml": "<kml>"+msg.payload.kml.Document[0].Placemark+"</kml>"
};
return msg;

You need to leave the kml as a string, just use a change node to move it to the correct property. Feel free to share some example kml and we'll show you.

eg

[{"id":"ea4fe99a.da6988","type":"inject","z":"d3236f0.2a14a9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":1220,"wires":[["4d5534e3.8c5f7c"]]},{"id":"4d5534e3.8c5f7c","type":"http request","z":"d3236f0.2a14a9","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://raw.githubusercontent.com/mapbox/Simple-KML/master/sample/example.kml","tls":"","persist":false,"proxy":"","authType":"","x":340,"y":1220,"wires":[["df81f2a3.3df45"]]},{"id":"df81f2a3.3df45","type":"change","z":"d3236f0.2a14a9","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.command.map.kml","tot":"msg"},{"t":"set","p":"payload.command.map.overlay","pt":"msg","to":"TestKML","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":1220,"wires":[["d1967997.d1aa58","992afe58.c194b"]]},{"id":"992afe58.c194b","type":"worldmap","z":"d3236f0.2a14a9","name":"","lat":"","lon":"","zoom":"5","layer":"","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"false","panlock":"false","zoomlock":"false","hiderightclick":"false","coords":"none","showgrid":"false","allowFileDrop":"false","path":"/worldmap","x":780,"y":1220,"wires":[]}]

Thanks so much @dceejay that was as easy as I thought it would be, I just had no idea it would be that easy!

Your flow 'just works'.

Can I change the icon to 'plane' in the change node?

You can add any fa-icon eg


But you can't set rotation

Perfect!

I just need to watch it for a while, I think the layer just keeps adding to itself.

Thanks for the worldmap node and for your help now getting it going with my KML file.

Cheers.

great - can you share an example kml ? thanks

Of course.
Here is what I am getting from the aircraft tracking program.

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Document>
<!-- Begin Style Definitions -->
<Style id="myAirStyles1">
<IconStyle id="khIconStyle791">
<color>ff00ffff</color>
<scale>1.0</scale>
<Icon>
<href>root://icons/palette-2.png</href>
<x>0</x>
<y>0</y>
<w>32</w>
<h>32</h>
</Icon>
</IconStyle>
<LabelStyle id="airLabelStyle1">
<color>ffffffff</color>
<scale>1.5</scale>
</LabelStyle>
<LineStyle id="airLineStyle1">
<color>ff0000ff</color>
<width>15</width>
</LineStyle>
<PolyStyle id="airPolyStyle1">
<color>7f7faaaa</color>
<colorMode>standard</colorMode>
</PolyStyle>
<BalloonStyle>
<text>
<![CDATA[<b>$[name]</b><br /><br/>$[description]]]>
</text>
</BalloonStyle>
</Style>
<Style id="myAirStyles2">
<IconStyle id="khIconStyle792">
<color>ffffffff</color>
<scale>1.0</scale>
<Icon>
<href>root://icons/palette-2.png</href>
<x>0</x>
<y>0</y>
<w>32</w>
<h>32</h>
</Icon>
</IconStyle>
<LabelStyle id="airLabelStyle2">
<color>ffffffff</color>
<scale>1.5</scale>
</LabelStyle>
<LineStyle id="airLineStyle2">
<color>ff0000ff</color>
<width>15</width>
</LineStyle>
<PolyStyle id="airPolyStyle2">
<color>7f7faaaa</color>
<colorMode>standard</colorMode>
</PolyStyle>
<BalloonStyle>
<text>
<![CDATA[<b>$[name]</b><br /><br/>$[description]]]>
</text>
</BalloonStyle>
</Style>
<Style id="myYellowTrackStyle">
<LineStyle>
<color>7f00ffff</color>
<width>1</width>
</LineStyle>
</Style>
<!-- End Style Definitions -->
<Placemark>
<name>
FDX614
</name>
<description>
TIME: 16:09:38  UTC<br />
</description>
<styleUrl>#myAirStyles1</styleUrl>
<Point>
<coordinates>-106.765340,37.647472,10000</coordinates>
<TimeStamp><when>2021-3-19T16:09:38 Z</when></TimeStamp></Point>
</Placemark>
<Placemark>
<name>
ACA301
</name>
<description>
TIME: 16:11:38  UTC<br />
</description>
<styleUrl>#myAirStyles1</styleUrl>
<Point>
<coordinates>-117.532649,49.837513,10000</coordinates>
<TimeStamp><when>2021-3-19T16:11:38 Z</when></TimeStamp></Point>
</Placemark>
<Placemark>
<name>
UAL284
</name>
<description>
TIME: 16:11:42  UTC<br />
</description>
<styleUrl>#myAirStyles1</styleUrl>
<Point>
<coordinates>-124.478768,30.183621,10000</coordinates>
<TimeStamp><when>2021-3-19T16:11:42 Z</when></TimeStamp></Point>
</Placemark>
<Placemark>
<name>
CPA806
</name>
<description>
ICA0: 780A65<br />
TIME: 16:12:02  UTC<br />
</description>
<styleUrl>#myAirStyles2</styleUrl>
<Point>
<coordinates>-110.395642,47.185339,10000</coordinates>
<TimeStamp><when>2021-3-19T16:12:02 Z</when></TimeStamp></Point>
</Placemark>
</Document>
</kml>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.