Serving Network KML

Hi All,
Just wondering if anyone has created a flow for serving KML data as a network link. I have have tried by modifying a basic web page example and replacing the html with KML code but it didn't work. I'm not sure if this is the correct way to do it or if I am completely on the wrong path.

@dmac101, if your kml data is stored in files you could do the following...
Create an end point that serves the files...

  • Http in -->
    • URL - "/kml/:filename"
  • function node -->
     msg.filename = '/folder/' + msg.req.params.filename
     return msg;
    
  • file in node -->
    • Leave file name blank (will use msg.filename set in previous function)
  • Http out/response node
    Set header Content-type to application/vnd.google-earth.kml+xml

Then you can access the kml files like this...

http://noderedip/kml/mykmlfile.kml

Where noderedip is the IP of the node red, mykmlfile.kml is the file name.

More info here

Similar solution here

Thanks Steve-Mcl. I was looking more at dynamically creating the KML and serving it.

I have tried this but when I link to it using GE, the link icon remains red and nothing is displayed.
If i browse to the address with a web browser I see the following

Simple placemark Attached to the ground. Intelligently places itself at the height of the underlying terrain. -122.0822035425683,37.42228990140251,0 `

[{"id":"87cd83c2.e4414","type":"template","z":"474c1029.4ec3f","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"plain","template":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n  <Placemark>\n    <name>Simple placemark</name>\n    <description>Attached to the ground. Intelligently places itself \n       at the height of the underlying terrain.</description>\n    <Point>\n      <coordinates>-122.0822035425683,37.42228990140251,0</coordinates>\n    </Point>`\n  </Placemark>\n</kml>","output":"str","x":560,"y":280,"wires":[["8698588b.c4d728"]]}]

Do you realise the flow you posted a single template node with hard coded xml/kml?

Also, I have no idea what "but when I link to it using GE, the link icon remains red and nothing is displayed" means? Is this in node-red? in node-red dashboard?

NOTE: your original question was about "Serving Network KML" not "dynamically creating the KML and serving it" which would have meant I wouldnt have bother describing loading of KML files etc - however, serving dynamic data (KML or whatever) and serving file data are preyty much the same task (just one doesn't load a file)

so if you want more help, please describe in detail your issue & dont assume we know what you mean by "the link icon remains red" - provide screen shots to clarify if necessary.