Not seeing coordinates on worldmap

[{"id":"b2c925db.9b5638","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"ac27147f.1ecc58","type":"buffer-parser","z":"b2c925db.9b5638","name":"Bulid Tags","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"byte","name":"lat","offset":6,"length":3,"offsetbit":0,"scale":1,"mask":""},{"type":"byte","name":"lon","offset":9,"length":3,"offsetbit":0,"scale":1,"mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"setTopic":true,"x":350,"y":160,"wires":[["12b41419.a1a1ac"]]},{"id":"12b41419.a1a1ac","type":"function","z":"b2c925db.9b5638","name":"","func":"var lat = (msg.payload.lat[0] << 24)  + (msg.payload.lat[1] << 16) + (msg.payload.lat[2] << 8) \nvar lon = (msg.payload.lon[0] << 24)  + (msg.payload.lon[1] << 16) + (msg.payload.lon[2] << 8) \n\nif (lat > 0x7FFFFFFF) { //  0x7FFFFFFF not 0x7FFFFFF\n  lat -= 0x100000000;\n}\n// else  << DONT DO IF ELSE HERE!\nif (lon > 0x7FFFFFFF) {  //  0x7FFFFFFF not 0x7FFFFFF\n  lon -= 0x100000000;\n}\n\nlat /= 10000000; //outside of the IF\nlon /= 10000000; //outside of the IF \n\nmsg.payload.lat=latitude\nmsg.payload.lon=longitude\n    \nmsg.origPayload = {\n    latitude: latitude,\n    longitude: longitude\n}\n\nreturn msg.origPayload;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":140,"wires":[["9f22db87.639b78"]]},{"id":"aa3e4429.aff7b8","type":"debug","z":"b2c925db.9b5638","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":730,"y":120,"wires":[]},{"id":"e857e2a1.d3861","type":"mqtt in","z":"b2c925db.9b5638","name":"","topic":"bachloo.rahul@gmail.com/test","qos":"0","datatype":"json","broker":"55bef158.86a7c","x":160,"y":40,"wires":[["cfcd456a.191e58"]]},{"id":"936eefa2.7b615","type":"base64","z":"b2c925db.9b5638","name":"","action":"","property":"payload","x":440,"y":80,"wires":[["ac27147f.1ecc58"]]},{"id":"cfcd456a.191e58","type":"function","z":"b2c925db.9b5638","name":"","func":"var t=msg.payload;\nmsg.payload=t.data;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":280,"y":100,"wires":[["936eefa2.7b615"]]},{"id":"9f22db87.639b78","type":"change","z":"b2c925db.9b5638","name":"set name","rules":[{"t":"set","p":"name","pt":"msg","to":"apple","tot":"str"},{"t":"set","p":"icon","pt":"msg","to":"fa-truck","tot":"str"},{"t":"set","p":"layer","pt":"msg","to":"markers","tot":"str"},{"t":"delete","p":"_msgid","pt":"msg"},{"t":"delete","p":"lat","pt":"msg"},{"t":"delete","p":"lon","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":240,"wires":[["aa3e4429.aff7b8","16b1288d.a68b37"]]},{"id":"16b1288d.a68b37","type":"worldmap-tracks","z":"b2c925db.9b5638","name":"GPS Tracks","depth":"20","layer":"combined","x":570,"y":300,"wires":[["95f1a239.2e3a5"]]},{"id":"95f1a239.2e3a5","type":"worldmap","z":"b2c925db.9b5638","name":"","lat":"","lon":"","zoom":"10","layer":"OSM","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"true","panlock":"false","zoomlock":"false","hiderightclick":"false","coords":"none","showgrid":"false","path":"/worldmap","x":700,"y":360,"wires":[]},{"id":"55bef158.86a7c","type":"mqtt-broker","name":"","broker":"maqiatto.com","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Hi, you should at least provide a description of what you attempting to do and where you are stuck.

Also, your flow is prett useless as people wont have access to your data and wont want to install other nodes like buffer parser.

Generate the smallest working flow with least amount of nodes WITH sample data so that people can test your flow and fix it for you...

I have flow which u shared so this might work
abeeway_microtracker.json (1.9 KB)
I basically want to plot gps coordinates i.e latitude and longitude using node red worldmap node.


upto this point i have reached but when i see worldmap it doesn't show coordinates.
Payload

{"latitude":28.3917568,"longitude":76.9600512,"_msgid":"803e9e46.ad97b","name":"apple","icon":"fa-truck","layer":"markers"}


As per the documentation...

The minimum msg.payload must contain name , lat and lon properties, for example

    msg.payload = { "name":"Jason", "lat":51.05, "lon":-1.35 }

It appears as though you are setting msg.lattitude instead of msg.payload.lat (and same issue for lon and name)


yes @steve i am receving this in debug window.but now i just want to extract payload out of whole msg.

Read the docs and re-read my last message.

.lat is NOT equal to .lattitude


yes made changes now but till now not able to see coordinates on worldmap.

No you havent, at least not correctly! Those values are NOT in msg.payload. Look at your screenshot.

Please check your work.

so how can i add them in msg.payload?

In your change node, dont put them in msg put them in msg.payload

change node...

  • First entry : Set msg.payload to JSON {} (make payload an empty object)
  • Second entry: Set msg payload.lat to msg lattitude
  • thrid entry: Set msg payload.lon to msg longitude
    and so on

or in a function node...

msg.payload = {
 lat: msg.lattitude,
 lon: msg.longitude,
 name: msg.name
}
return msg;

Different perspective, as it might help to understand what is going on. Here’s the longer version described. https://nodered.org/docs/user-guide/messages

Every message in node red is an object. This object holds a number of properties, including the “_msgid” from your previous topic, and a “payload” property. This payload is used by nodes as the content, so to say. The worldmap node is looking for payloads that are objects themselves, with a set of mandatory properties on them, such as name, lat and lon.
In the structure of your entire message, these properties are set on the payload, rather than the message object itself.

I hope that gives you the background you’re looking for, as for the rest Steve’s instructions are the way to go.

1 Like


please steve share ur flow i am unable to do using my flow.or u can modify this flow

[{"id":"168049bc.7f2556","type":"change","z":"f1c3712a.51632","name":"set name","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"json"},{"t":"set","p":"payload.name","pt":"msg","to":"apple","tot":"str"},{"t":"set","p":"payload.icon","pt":"msg","to":"fa-truck","tot":"str"},{"t":"set","p":"payload.layer","pt":"msg","to":"markers","tot":"str"},{"t":"set","p":"_msgid","pt":"msg","to":"payload._msgid","tot":"msg"},{"t":"set","p":"payload.lat","pt":"msg","to":"lat","tot":"msg"},{"t":"set","p":"payload.lon","pt":"msg","to":"lon","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":200,"wires":[["40ae8e7f.0cd12"]]}]

image

I think it would save everyone a lot of time if you spend an hour watching the Node Red Essentials videos linked from the node red docs, than reading carefully the page that @afelix linked to. If you don't understand anything then ask. Once you understand all that you should be able to do it yourself easily.

1 Like

I concur fully with Colin and Lena.

watch this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

I will also add this is not the first time we have spent our time trying to get you to understand some of the basic principles of working with message properties.

There was a thread a month ago from you on exactly the same topic.


yes made the changes according to you this is the output.

Looks like in some other adjustment you have you deleted the msg.lattitude and msg.longitude - thats why they are missing.

I am sorry - I tried to lead you to the answer so that you can become proficient.

Post your flow as it is now and I will fix it for you - but note - this is not really a good way to help you I hope you realise.

@steve I have not deleted anything for sure as far as i can remember.

[{"id":"f1c3712a.51632","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"c573d354.4e202","type":"buffer-parser","z":"f1c3712a.51632","name":"Bulid Tags","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"byte","name":"lat","offset":6,"length":3,"offsetbit":0,"scale":1,"mask":""},{"type":"byte","name":"lon","offset":9,"length":3,"offsetbit":0,"scale":1,"mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"setTopic":true,"x":350,"y":160,"wires":[["bafbdd1c.dbce3"]]},{"id":"bafbdd1c.dbce3","type":"function","z":"f1c3712a.51632","name":"","func":"var lat = (msg.payload.lat[0] << 24)  + (msg.payload.lat[1] << 16) + (msg.payload.lat[2] << 8) \nvar lon = (msg.payload.lon[0] << 24)  + (msg.payload.lon[1] << 16) + (msg.payload.lon[2] << 8) \n\nif (lat > 0x7FFFFFFF) { //  0x7FFFFFFF not 0x7FFFFFF\n  lat -= 0x100000000;\n}\n// else  << DONT DO IF ELSE HERE!\nif (lon > 0x7FFFFFFF) {  //  0x7FFFFFFF not 0x7FFFFFF\n  lon -= 0x100000000;\n}\n\nlat /= 10000000; //outside of the IF\nlon /= 10000000; //outside of the IF \n\nvar latitude,longitude;\n\nmsg.payload.lat = latitude;\nmsg.payload.lon = longitude;\n\nreturn msg.payload;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":140,"wires":[["168049bc.7f2556"]]},{"id":"40ae8e7f.0cd12","type":"debug","z":"f1c3712a.51632","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":730,"y":120,"wires":[]},{"id":"56b1735a.72088c","type":"mqtt in","z":"f1c3712a.51632","name":"","topic":"bachloo.rahul@gmail.com/test","qos":"0","datatype":"json","broker":"55bef158.86a7c","x":160,"y":40,"wires":[["2290cb3c.d51354"]]},{"id":"e9da35ff.a1ad48","type":"base64","z":"f1c3712a.51632","name":"","action":"","property":"payload","x":420,"y":80,"wires":[["c573d354.4e202"]]},{"id":"2290cb3c.d51354","type":"function","z":"f1c3712a.51632","name":"","func":"var t=msg.payload;\nmsg.payload=t.data;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":260,"y":100,"wires":[["e9da35ff.a1ad48"]]},{"id":"168049bc.7f2556","type":"change","z":"f1c3712a.51632","name":"set name","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.lat","pt":"msg","to":"latitude","tot":"msg"},{"t":"set","p":"payload.lon","pt":"msg","to":"longitude","tot":"msg"},{"t":"set","p":"payload.name","pt":"msg","to":"apple","tot":"str"},{"t":"set","p":"payload.icon","pt":"msg","to":"fa-truck","tot":"str"},{"t":"set","p":"payload.layer","pt":"msg","to":"markers","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":200,"wires":[["40ae8e7f.0cd12"]]},{"id":"38833219.eed1ee","type":"worldmap-tracks","z":"f1c3712a.51632","name":"GPS Tracks","depth":"20","layer":"combined","x":530,"y":340,"wires":[["dedad9e1.d48fb8"]]},{"id":"dedad9e1.d48fb8","type":"worldmap","z":"f1c3712a.51632","name":"","lat":"","lon":"","zoom":"10","layer":"OSM","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"true","panlock":"false","zoomlock":"false","hiderightclick":"false","coords":"none","showgrid":"false","path":"/worldmap","x":700,"y":320,"wires":[]},{"id":"55bef158.86a7c","type":"mqtt-broker","name":"","broker":"maqiatto.com","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

change the function AFTER the buffer parser to this...

var lat = (msg.payload.lat[0] << 24)  + (msg.payload.lat[1] << 16) + (msg.payload.lat[2] << 8) 
var lon = (msg.payload.lon[0] << 24)  + (msg.payload.lon[1] << 16) + (msg.payload.lon[2] << 8) 

if (lat > 0x7FFFFFFF) { 
  lat -= 0x100000000;
}

if (lon > 0x7FFFFFFF) {
  lon -= 0x100000000;
}

lat /= 10000000; 
lon /= 10000000;

msg.payload.lat = lat ;
msg.payload.lon = lon ;
msg.payload.name = "apple"; //set name
msg.payload.icon = "fa-truck";  //set icon
msg.payload.marker = "layer"; //set marker

//return msg.payload; WRONG - always return msg!
return msg;

and delete the change node