# Live updating Worldmap with kml data

**URL:** <https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824>\
**Category:** General\
**Created:** [18 March 2021 14:23 UTC](https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824 "2021-03-18T14:23:19Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![thebaldgeek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thebaldgeek/32/93523_2.png) [@thebaldgeek](https://discourse.nodered.org/u/thebaldgeek)\
**Post date:** [18 March 2021 14:23 UTC](https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824/1 "2021-03-18T14:23:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [18 March 2021 15:14 UTC](https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824/2 "2021-03-18T15:14:50Z")

</div>

You can add kml as an overlay - like [GitHub - dceejay/RedMap: A web map app for Node-RED to put blobs on](https://github.com/dceejay/RedMap#to-add-a-new-kml-gpx-or-topojson-overlay)

---

<div class="post-metadata">

**Author:** ![thebaldgeek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thebaldgeek/32/93523_2.png) [@thebaldgeek](https://discourse.nodered.org/u/thebaldgeek)\
**Post date:** [19 March 2021 01:08 UTC](https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824/3 "2021-03-19T01:08:13Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/a/ea7b6002f2063b276c2859cf787c522d71b292f0.png)

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 March 2021 01:18 UTC](https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824/4 "2021-03-19T01:18:23Z")

</div>

> [@thebaldgeek](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![thebaldgeek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thebaldgeek/32/93523_2.png) [@thebaldgeek](https://discourse.nodered.org/u/thebaldgeek)\
**Post date:** [19 March 2021 01:37 UTC](https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824/5 "2021-03-19T01:37:55Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/7/3751e7438480e88ab7ee28036e5b154b05f29dca.png)  
Here is the object after the xml node.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/52534ffcc5e4c604902738e42d1c530eaf2e25f2.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/1/f166660f8714cc51444dddb39d7be2a4a292aed6.png)

The error is the same.

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

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [19 March 2021 07:14 UTC](https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824/6 "2021-03-19T07:14:28Z")

</div>

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

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![thebaldgeek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thebaldgeek/32/93523_2.png) [@thebaldgeek](https://discourse.nodered.org/u/thebaldgeek)\
**Post date:** [19 March 2021 09:07 UTC](https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824/7 "2021-03-19T09:07:22Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/7/a7cc3738480a8042de95148ea6cfe8daf4710b46.jpeg)

Your flow 'just works'.

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

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [19 March 2021 09:36 UTC](https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824/8 "2021-03-19T09:36:55Z")

</div>

You can add any fa-icon eg

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/1/d125cf589bc8aca4660bb5f68035e59e38615e92.png)  
But you can't set rotation

---

<div class="post-metadata">

**Author:** ![thebaldgeek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thebaldgeek/32/93523_2.png) [@thebaldgeek](https://discourse.nodered.org/u/thebaldgeek)\
**Post date:** [19 March 2021 09:42 UTC](https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824/9 "2021-03-19T09:42:59Z")

</div>

Perfect!

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/70010db16ecdc0933c2b11ae10c33922e66160bf.jpeg)

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.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [19 March 2021 13:23 UTC](https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824/10 "2021-03-19T13:23:28Z")

</div>

great - can you share an example kml ? thanks

---

<div class="post-metadata">

**Author:** ![thebaldgeek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thebaldgeek/32/93523_2.png) [@thebaldgeek](https://discourse.nodered.org/u/thebaldgeek)\
**Post date:** [19 March 2021 16:16 UTC](https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824/11 "2021-03-19T16:16:34Z")

</div>

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

```auto
<?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>

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 April 2021 16:17 UTC](https://discourse.nodered.org/t/live-updating-worldmap-with-kml-data/42824/12 "2021-04-02T16:17:18Z")

</div>

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