World Map don't maintain the Marker when restart the page

Hello to everyone!

I have a problem with the Worldmap in the dashboard. When i configure the worldmap, the Lat and Lon was set according to a function that i have to the worldmap, here are the images.

Before restart the page:

But when i restart the page, The marker was deleted.

Here is the flow:


the function:

Thank for your time!

  1. what do you mean by 'when i restart the page'? do you mean you refresh the browser window? restart node-red? Send more data to the world map node?
  2. what version of NR, node.js and the world map node are you running?
  3. what is the full node name of the 'webhookrelay node?
  4. have you tried adding a debug node to the output of the webhookrelay and function nodes to see what is coming thru?

Please answer all of the questions and after testing with the debug notes, exported your updated flow and pasted it to a reply.

I had similar issue using Worldmap and Owntracks. I added a UI Control Node that would resend the lat/lon information every time that the webpage changed. I am not sure if that is correct or best solution but it works in my situation. I didn't see any option in the Worldmap Node to retain the information natively.

1 Like

Yes, is something like that. Can you show me that solution?

@stephenn

Hello, thank for your time, here are the answers.

1- What i try to mean is refresh the browser window the UI
2- ND version is v3.0.2. And world map 2.33.0
3- The node is : webhookrelay


4- Yes, i´ve tested the debug node. Look at this.

The explain about the flow, is a Weather station and this station send location like lat and long.
The weather station data comes thanks to webhook node.

I´m going to send you all flow.

[
    {
        "id": "5281569755289f03",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "793c738f6b9a72ab",
        "type": "json",
        "z": "5281569755289f03",
        "name": "",
        "property": "payload",
        "action": "obj",
        "pretty": false,
        "x": 270,
        "y": 80,
        "wires": [
            [
                "267ac645fc76b286"
            ]
        ]
    },
    {
        "id": "267ac645fc76b286",
        "type": "change",
        "z": "5281569755289f03",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.body",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 420,
        "y": 80,
        "wires": [
            [
                "587a5e219d39d57c"
            ]
        ],
        "info": "payload.body"
    },
    {
        "id": "587a5e219d39d57c",
        "type": "json",
        "z": "5281569755289f03",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 570,
        "y": 80,
        "wires": [
            [
                "76bef98b25e7fc54"
            ]
        ]
    },
    {
        "id": "76bef98b25e7fc54",
        "type": "change",
        "z": "5281569755289f03",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "longitude",
                "pt": "msg",
                "to": "payload.measurements[0].longitude",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "latitude",
                "pt": "msg",
                "to": "payload.measurements[0].latitude",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 720,
        "y": 80,
        "wires": [
            [
                "fc08b6bf231171c0"
            ]
        ]
    },
    {
        "id": "fc08b6bf231171c0",
        "type": "function",
        "z": "5281569755289f03",
        "name": "move and zoom",
        "func": "msg.payload = { \"name\": \"Estacion\", \"lat\": msg.latitude, \"lon\": msg.longitude, zoom: 10} \nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 900,
        "y": 80,
        "wires": [
            [
                "0b677e3dd2ba8b02",
                "dc342a17a2c9da65"
            ]
        ]
    },
    {
        "id": "4cdd312ca769e9b9",
        "type": "webhookrelay",
        "z": "5281569755289f03",
        "buckets": "nodered",
        "x": 120,
        "y": 80,
        "wires": [
            [
                "793c738f6b9a72ab"
            ]
        ]
    },
    {
        "id": "0b677e3dd2ba8b02",
        "type": "ui_worldmap",
        "z": "5281569755289f03",
        "group": "ddba28a6f30ecd3c",
        "order": 1,
        "width": 0,
        "height": 0,
        "name": "",
        "lat": "",
        "lon": "",
        "zoom": "12",
        "layer": "OSMC",
        "cluster": "4",
        "maxage": "",
        "usermenu": "show",
        "layers": "show",
        "panit": "true",
        "panlock": "true",
        "zoomlock": "true",
        "hiderightclick": "true",
        "coords": "deg",
        "showgrid": "false",
        "showruler": "true",
        "allowFileDrop": "true",
        "path": "/worldmap",
        "overlist": "DR,CO,RA,DN,HM",
        "maplist": "OSMG,OSMC,OSMH,EsriC,EsriS,EsriT,EsriDG,UKOS",
        "mapname": "",
        "mapurl": "",
        "mapopt": "",
        "mapwms": false,
        "x": 1060,
        "y": 40,
        "wires": []
    },
    {
        "id": "dc342a17a2c9da65",
        "type": "debug",
        "z": "5281569755289f03",
        "name": "debug 25",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1060,
        "y": 120,
        "wires": []
    },
    {
        "id": "ddba28a6f30ecd3c",
        "type": "ui_group",
        "name": "Ubicacion",
        "tab": "e3d9fea785419dc6",
        "order": 1,
        "disp": true,
        "width": 28,
        "collapse": false,
        "className": ""
    },
    {
        "id": "e3d9fea785419dc6",
        "type": "ui_tab",
        "name": "Ubicacion de la estacion",
        "icon": "place",
        "order": 4,
        "disabled": false,
        "hidden": false
    }
]

For an Example, webhook node give me this JSON:

object
deviceName: "Weather Station"
deviceSerialNumber: "CM.S2B.1.1.0-N0000117"
measurements: array[6]
0: object
latitude: 6.071770000000001
longitude: -75.33387
name: "location"
1: object
data: 3
name: "air-quality"
2: object
data: 15.740000000000002
name: "temperature"
3: object
data: 97.48
name: "humidity"
4: object
data: 240
data2: 0.625
name: "wind-speed"
5: object
data: 4045
name: "battery"
timestamp: "2022-11-28T18:00:01Z"

Thank you for your time and i hope this information help.

This is my flow. No idea if it is most efficient solution.

This tracks my location and my wife's. Every time that a new msg comes from Owntracks MQTT, the value is stored in a flow variable (Top and Bottom legs of flow toward the Worldmap nodes). Also, the flow proceeds to a Function Nodes which converts to a format for Worldmap.

Then, when the UI Control node (middle leg of flow toward the Worldmap node) notices a change in either of the 2 Owntracks Tabs, a Change Node pulls the values from the respective flow variables and sends on to Worldmap Node via similar Function Nodes. I have a Worldmap for a desktop computer and one for mobile.

Ohhhhhhh, ok.

For me, the Station the most of the time will be at the same point, no change unlike your case. But i think that could work.

Can you send me the flow??

Try this. I have only shared a flow a couple of times.

[{"id":"84d146c063faa97f","type":"switch","z":"1e8ddbf5b4e915cc","name":"Confirm Change is an Owntracks Tab","property":"name","propertyType":"msg","rules":[{"t":"eq","v":"OWNTRACKS","vt":"str"},{"t":"eq","v":"OWNTRACKS MOBILE","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":240,"wires":[["7727eded253191e0","3580fc93f9b56945"],["7727eded253191e0","3580fc93f9b56945"]]},{"id":"3daed54053a35499","type":"switch","z":"1e8ddbf5b4e915cc","name":"Dashboard Change Only","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"change","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":330,"y":240,"wires":[["84d146c063faa97f"]]},{"id":"7727eded253191e0","type":"change","z":"1e8ddbf5b4e915cc","name":"msg.payload to flow.snLocationStorage","rules":[{"t":"set","p":"payload","pt":"msg","to":"snLocationStorage","tot":"flow","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":200,"wires":[["75dd68ca2131e72c"]]},{"id":"3580fc93f9b56945","type":"change","z":"1e8ddbf5b4e915cc","name":"msg.payload to flow.knLocationStorage","rules":[{"t":"set","p":"payload","pt":"msg","to":"knLocationStorage","tot":"flow","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":280,"wires":[["f2ef075d453b3ada"]]},{"id":"0dc56d153e5dfce1","type":"ui_ui_control","z":"1e8ddbf5b4e915cc","name":"","events":"all","x":100,"y":240,"wires":[["3daed54053a35499"]]},{"id":"75dd68ca2131e72c","type":"function","z":"1e8ddbf5b4e915cc","name":"Extract lat, lon","func":"let out = [];  // Declare an array\n\nlet id  = \"ISS\";\nlet lat = \"\";\nlet lon = \"\";\n\nlon = msg.payload.lon;\nlat = msg.payload.lat;\n\nout.push({ \"name\": \"Stephen\", \"lat\": lat, \"lon\": lon, \"layer\": \"GPS Location\", \"icon\": \"fa-car\", \"iconColor\": \"#0000FF\"});\n\nmsg.payload = out;\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1260,"y":200,"wires":[["32e789f00a6cd91d"]]},{"id":"f2ef075d453b3ada","type":"function","z":"1e8ddbf5b4e915cc","name":"Extract lat, lon","func":"let out = [];  // Declare an array\n\nlet id  = \"ISS\";\nlet lat = \"\";\nlet lon = \"\";\n\nlon = msg.payload.lon;\nlat = msg.payload.lat;\n\nout.push({ \"name\": \"Kristy\", \"lat\": lat, \"lon\": lon, \"layer\": \"GPS Location\", \"icon\": \"fa-exclamation-circle\", \"iconColor\":\"#FF0000\"});\n\nmsg.payload = out;\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1260,"y":280,"wires":[["d03f69bc82624820"]]},{"id":"32e789f00a6cd91d","type":"delay","z":"1e8ddbf5b4e915cc","name":"","pauseType":"delay","timeout":"1500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1460,"y":200,"wires":[["605c9ce313e4a5a7","51b4f4b01c2a9c74"]]},{"id":"d03f69bc82624820","type":"delay","z":"1e8ddbf5b4e915cc","name":"","pauseType":"delay","timeout":"2500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1460,"y":280,"wires":[["605c9ce313e4a5a7","51b4f4b01c2a9c74"]]},{"id":"605c9ce313e4a5a7","type":"ui_worldmap","z":"1e8ddbf5b4e915cc","group":"db43231dfc240cf4","order":1,"width":"20","height":"20","name":"OWNTRACKS FOR PC","lat":"39.481049","lon":"-76.6049","zoom":"15","layer":"OSMC","cluster":"","maxage":"0","usermenu":"show","layers":"show","panit":"true","panlock":"false","zoomlock":"false","hiderightclick":"true","coords":"none","showgrid":"false","showruler":"true","allowFileDrop":"false","path":"/worldmap","overlist":"DN","maplist":"OSMG,OSMC,EsriS","mapname":"","mapurl":"","mapopt":"","mapwms":false,"x":1730,"y":200,"wires":[]},{"id":"51b4f4b01c2a9c74","type":"ui_worldmap","z":"1e8ddbf5b4e915cc","group":"58aafd33631fb59c","order":1,"width":"7","height":"11","name":"OWNTRACKS MOBILE","lat":"39.481049","lon":"-76.6049","zoom":"15","layer":"OSMC","cluster":"","maxage":"0","usermenu":"show","layers":"show","panit":"true","panlock":"false","zoomlock":"false","hiderightclick":"true","coords":"none","showgrid":"false","showruler":"true","allowFileDrop":"false","path":"/worldmap","overlist":"DN","maplist":"OSMG,OSMC,EsriS","mapname":"","mapurl":"","mapopt":"","mapwms":false,"x":1730,"y":280,"wires":[]},{"id":"6b32ca2b8bafb6cf","type":"function","z":"1e8ddbf5b4e915cc","name":"Extract lat, lon","func":"let out = [];  // Declare an array\n\nlet id  = \"ISS\";\nlet lat = \"\";\nlet lon = \"\";\n\nlon = msg.payload.lon;\nlat = msg.payload.lat;\n\nout.push({ \"name\": \"Stephen\", \"lat\": lat, \"lon\": lon, \"layer\": \"GPS Location\", \"icon\": \"fa-car\", \"iconColor\": \"#0000FF\"});\n\nmsg.payload = out;\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1460,"y":140,"wires":[["605c9ce313e4a5a7","51b4f4b01c2a9c74"]]},{"id":"f8a34dfed2242751","type":"function","z":"1e8ddbf5b4e915cc","name":"Extract lat, lon","func":"let out = [];  // Declare an array\n\nlet id  = \"ISS\";\nlet lat = \"\";\nlet lon = \"\";\n\nlon = msg.payload.lon;\nlat = msg.payload.lat;\n\nout.push({ \"name\": \"Kristy\", \"lat\": lat, \"lon\": lon, \"layer\": \"GPS Location\", \"icon\": \"fa-exclamation-circle\", \"iconColor\":\"#FF0000\"});\n\nmsg.payload = out;\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1460,"y":340,"wires":[["605c9ce313e4a5a7","51b4f4b01c2a9c74"]]},{"id":"bada1eaa77f2d80d","type":"switch","z":"1e8ddbf5b4e915cc","name":"","property":"payload._type","propertyType":"msg","rules":[{"t":"neq","v":"lwt","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":390,"y":140,"wires":[["3f9bd6d7668cbc4f","6b32ca2b8bafb6cf"]]},{"id":"d47f1622cef3dd7e","type":"switch","z":"1e8ddbf5b4e915cc","name":"","property":"payload._type","propertyType":"msg","rules":[{"t":"neq","v":"lwt","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":390,"y":340,"wires":[["f8a34dfed2242751","5247d3537288e6b1"]]},{"id":"7604cf1d5d86fd7d","type":"mqtt in","z":"1e8ddbf5b4e915cc","name":"","topic":"owntracks/user/stephenn","qos":"1","datatype":"auto-detect","broker":"6f56c4a505eefb4e","nl":false,"rap":true,"rh":0,"inputs":0,"x":150,"y":140,"wires":[["bada1eaa77f2d80d"]]},{"id":"3f9bd6d7668cbc4f","type":"change","z":"1e8ddbf5b4e915cc","name":"","rules":[{"t":"set","p":"snLocationStorage","pt":"flow","to":"payload","tot":"msg","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":100,"wires":[[]]},{"id":"3e3ee98fda75d9a9","type":"mqtt in","z":"1e8ddbf5b4e915cc","name":"","topic":"owntracks/kn/kristyn","qos":"1","datatype":"auto-detect","broker":"6f56c4a505eefb4e","nl":false,"rap":true,"rh":0,"inputs":0,"x":170,"y":340,"wires":[["d47f1622cef3dd7e"]]},{"id":"5247d3537288e6b1","type":"change","z":"1e8ddbf5b4e915cc","name":"","rules":[{"t":"set","p":"knLocationStorage","pt":"flow","to":"payload","tot":"msg","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":380,"wires":[[]]},{"id":"db43231dfc240cf4","type":"ui_group","name":"OWNTRACKS","tab":"3dc1077949390c9b","order":1,"disp":true,"width":"20","collapse":false,"className":""},{"id":"58aafd33631fb59c","type":"ui_group","name":"MOBILE","tab":"d33a5708af3da3dc","order":2,"disp":true,"width":"7","collapse":false,"className":""},{"id":"6f56c4a505eefb4e","type":"mqtt-broker","name":"MQTT on 203","broker":"192.168.1.203","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"3dc1077949390c9b","type":"ui_tab","name":"OWNTRACKS","icon":"dashboard","order":1,"disabled":false,"hidden":false},{"id":"d33a5708af3da3dc","type":"ui_tab","name":"OWNTRACKS MOBILE","icon":"dashboard","disabled":false,"hidden":false}]

@stephenn I was looking at your flow and started playing with it. You can reduce it quite a bit. For example I combined the two flows with mqtt-in's into one flow. Stick a debug node on the output of the two function nodes in the owntrack flows and configure the mqtt-in node with the broker and check compare the outputs, they should be the same.

[{"id":"9169c093105bbd0f","type":"switch","z":"c5a6f87d32758266","name":"filter out LWT","property":"payload._type","propertyType":"msg","rules":[{"t":"neq","v":"lwt","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"_mcu":{"mcu":false},"x":370,"y":600,"wires":[["55f7b348b9da83aa"]]},{"id":"7d3106f20b66c4c9","type":"mqtt in","z":"c5a6f87d32758266","name":"","topic":"owntracks/#","qos":"1","datatype":"auto-detect","broker":"6f56c4a505eefb4e","nl":false,"rap":true,"rh":0,"inputs":0,"_mcu":{"mcu":false},"x":130,"y":600,"wires":[["9169c093105bbd0f"]]},{"id":"580b74d9e705c211","type":"change","z":"c5a6f87d32758266","name":"Fill in Stephenn's data","rules":[{"t":"set","p":"snLocationStorage","pt":"flow","to":"payload","tot":"msg","dc":true},{"t":"set","p":"user","pt":"msg","to":"stephenn","tot":"str"},{"t":"set","p":"icon","pt":"msg","to":"fa-car","tot":"str"},{"t":"set","p":"color","pt":"msg","to":"#0000FF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"_mcu":{"mcu":false},"x":740,"y":580,"wires":[["31653eb2c5ca8b19"]]},{"id":"55f7b348b9da83aa","type":"switch","z":"c5a6f87d32758266","name":"which user","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"stephenn","vt":"str"},{"t":"cont","v":"kristyn","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"_mcu":{"mcu":false},"x":530,"y":600,"wires":[["580b74d9e705c211"],["ba9a2e186d236d64"]]},{"id":"ba9a2e186d236d64","type":"change","z":"c5a6f87d32758266","name":"Fill in Kristy's data","rules":[{"t":"set","p":"knLocationStorage","pt":"flow","to":"payload","tot":"msg","dc":true},{"t":"set","p":"user","pt":"msg","to":"Kristy","tot":"str"},{"t":"set","p":"icon","pt":"msg","to":"fa-exclamation-circle","tot":"str"},{"t":"set","p":"color","pt":"msg","to":"#FF0000","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"_mcu":{"mcu":false},"x":730,"y":620,"wires":[["31653eb2c5ca8b19"]]},{"id":"31653eb2c5ca8b19","type":"change","z":"c5a6f87d32758266","name":"build map object","rules":[{"t":"set","p":"mapdata","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"mapdata.name","pt":"msg","to":"user","tot":"msg"},{"t":"set","p":"mapdata.lat","pt":"msg","to":"payload.lat","tot":"msg"},{"t":"set","p":"mapdata.lon","pt":"msg","to":"payload.lon","tot":"msg"},{"t":"set","p":"mapdata.layer","pt":"msg","to":"GPS Location","tot":"str"},{"t":"set","p":"mapdata.icon","pt":"msg","to":"icon","tot":"msg"},{"t":"set","p":"mapdata.iconColor","pt":"msg","to":"color","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload[0]","pt":"msg","to":"mapdata","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"_mcu":{"mcu":false},"x":990,"y":600,"wires":[["92a097adf871e5b6"]]},{"id":"92a097adf871e5b6","type":"debug","z":"c5a6f87d32758266","name":"debug 200","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","_mcu":{"mcu":false},"x":1210,"y":600,"wires":[]},{"id":"6f56c4a505eefb4e","type":"mqtt-broker","name":"MQTT on 203","broker":"192.168.1.203","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]```
1 Like

Why would you do that? Why would I want a more efficient flow? hahahahahaha

Thank you sir. After finally getting it to work last week, I hadn't gone back to it to yet to see how to clean it up. My biggest struggle was retaining the values which was the OP question.

Hahaha, it was funny. But my worldmap stills no working.


x

Someone @stephenn or @zenofmud Could you help me?


The delay node was the only thing that i added.

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