Remembering position on UI dashboard with worldmap

Hello
I have setup an IoT device which passes co-ordinates to a worldmap node on my node-red UI dashboard on bluemix

The problem is, is when I close the UI dashboard website and re-open it, it has to wait for a co-ordinate from my IoT device before focusing in and nominating the location of it.

Is there a way I can have the UI dashboard remember the last location sent from my IoT device on the map? So, if I close the dashboard and re-open it, it re-opens to the last known co-ordinates that were sent?

The map needs to be send the location in order to display it.
So if you save the location, you can trigger it to be sent to the map.

How you capture that connection is covered in the readme for the world map node

1 Like

Thanks for the reply

So are you saying I need to store those coordinates in some sort of cloud database then extract and send it to the worldmap node?

No, thats not what I said.
You said you wanted to store the last known coordinates. If its that simple you could store it in context variables (look at the docs)

OK Thanks. I had a read of all of that and tried to set it up in my flow, however it still will not remember the position after I close and re-open the UI.

Here is an extract of my flow diagram:

Store_GPS:

flow.set("latit", msg.payload.latitude);
flow.set("longit", msg.payload.longitude);

return msg;

GPS_Map:

var long = flow.get("latit");
var lat = flow.get("longit");
msg.payload={lat:flow.get("lat"), lon:flow.get("long"), name:"1CEE2B",  "radius": 2000, url:"<a href=\"../ui/#/0\">IBM link</a>"};

return msg;

Time decoder:

function returnTime(value){
return new Date((value)*1000 + 39600000);
}

var time = msg.payload.time;
msg.payload.time = '' + returnTime(time).toLocaleString();
return msg;

What @ukmoose was hinting you towards was this section of the readme - https://flows.nodered.org/node/node-red-contrib-web-worldmap#events-from-the-map , the first example. You can use that to trigger sending the basic co-ordinates again.

Thanks for the reply

Sorry, I'm new to this and I don't understand how to implement that. Can someone show me an example? I looked in all the examples tha came with the worldmap node and cannot work out how to do it.

Add a debug to the map in node and set the debug to display all the message.

Then try browsing to the worldmap page. What do you see back in the debug?
Use a switch node to only get the message you are interested in.

Got it, thanks!