Dynamic URL in iframe in UI template

1,037 views
Skip to first unread message

Erwin Kooi

unread,
Oct 5, 2016, 8:36:54 AM10/5/16
to Node-RED
Hej! Does anyone know if it is possible to render an iframe in a Node-Red UI template node with a dynamic url?

What I try to do: Get a map with locator based on the coordinates my phone transmits via OwnTracks -> MQTT -> MyBroker -> Node-Red UI.

I have constructed the correct url for OpenStreetMaps using the reported coordinates: 
msg.payload.url  = "http://www.openstreetmap.org/export/embed.html?bbox=" + Number(msg.payload.lon - 0.02).toFixed(4) + "," + Number(msg.payload.lat - 0.02).toFixed(4) + "," + Number(msg.payload.lon + 0.02).toFixed(4) + "," +  Number(msg.payload.lat + 0.02).toFixed(4) + "&layer=mapnik&marker=" + msg.payload.lat + "," + msg.payload.lon;

Dropping this url in a browser renders the expected result.

When I try to use this msg.payload.url in a UI template node in an iframe src={{msg.payload.url}}, the dashboard complains it cannot find the url  /ui/{{msg.payload.url}}.

When I construct the entire iframe code in a function node 
msg.payload.iframe = "<iframe width=300 height=300 frameborder=0 scrolling=no marginheight=0 marginwidth=0 src=" + msg.payload.url + " style={border: 1px solid black}></iframe>";
and do a 
<div ng-bind-html="msg.payload.iframe"></div>
Nothing is shown. 

If I print the iframe code using a text UI node and copy-paste that text into a temporary index.html on my desktop and open that with a browser, everything works as expected.

I have really no clues left...

Julian Knight

unread,
Oct 5, 2016, 10:02:33 AM10/5/16
to Node-RED
Not sure of the answer on this but I'm wondering if it wouldn't be easier to use the Leaflet library?

Erwin Kooi

unread,
Oct 5, 2016, 10:58:35 AM10/5/16
to Node-RED
Thnx! Researching...

Dave C-J

unread,
Oct 5, 2016, 1:13:43 PM10/5/16
to node...@googlegroups.com

Or see if node-red-contrib-web-worldmap helps

Julian Knight

unread,
Oct 5, 2016, 1:23:29 PM10/5/16
to Node-RED
Sorry Dave, I forgot your excellent node! :)
Reply all
Reply to author
Forward
0 new messages