Hi!
I have a question. I currently am logging my GPS data to a .txt file in this format:
{"name":"8XEhx", "lat":40505, "lon":16, "time":"16:33:45"}
{"name":"6YgrX", "lat":40505, "lon":11296, "time":"16:33:45"}
{"name":"Ihg8J", "lat":5, "lon":196, "time":"16:33:46"}
{"name":"WvFme", "lat":430505, "lon":16, "time":"16:33:46"}
{"name":"Hn8TA", "lat":40505, "lon":161667, "time":"16:33:47"}
{"name":"ieLH7", "lat":40505, "lon":192961667, "time":"16:33:47"}
Now I would like to have a function to show those Points on a map.
Somehow it doesnt work properly.
What I thought is, that if you want to put points to a map you have to have something like this:
msg.payload = [
{"name":"8XEhx", lat:45, lon:19296},
{"name":"6YgrX", lat:8.130505, lon:1296},
{"name":"Ihg8J", lat:0505, lon:19296},
{"name":"WvFme", lat:0505, lon:1296},
{"name":"Hn8TA", lat:4505, lon:167},
{"name":"ieLH7", lat:48505, lon:11667}]
return msg;
Note that those are not my actual coordinates in the example.
this is my flow:
[
{
"id": "1874e22aa1362f24",
"type": "ui_button",
"z": "b423c3276f31428e",
"name": "",
"group": "160e81fb.f1c86e",
"order": 9,
"width": 2,
"height": 1,
"passthru": false,
"label": "Plot",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "show_chart",
"payload": "",
"payloadType": "str",
"topic": "",
"topicType": "str",
"x": 90,
"y": 1300,
"wires": [
[
"382bea699b9b89f9"
]
]
},
{
"id": "382bea699b9b89f9",
"type": "function",
"z": "b423c3276f31428e",
"name": "Get filename",
"func": "// Get the filename from the flow context\nlet filename = flow.get(\"fileselected\");\n\n// check, if the filename is undefined that means it does not exist yet, nothing is selected yet\n// return: do not output anything\nif (filename===undefined) {\n return;\n}\n\n// return the filename to the file-in node to delete\nmsg.filename = filename;\n\nif (msg.filename.replace(/^.*(\\\\|\\/|\\:)/, '')[0]!==\".\") {\n // Only do this if this is a file, we don't delete folders\n return msg;\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 260,
"y": 1300,
"wires": [
[
"02f194100e923b62"
]
]
},
{
"id": "02f194100e923b62",
"type": "file in",
"z": "b423c3276f31428e",
"name": "",
"filename": "",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 440,
"y": 1300,
"wires": [
[
"491e65281f27f4d8"
]
]
},
{
"id": "d701d7d889e4b605",
"type": "debug",
"z": "b423c3276f31428e",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 630,
"y": 1220,
"wires": []
},
{
"id": "3113ccc41272a67f",
"type": "function",
"z": "b423c3276f31428e",
"name": "Format data for chart",
"func": "var lines = msg.payload.split(\"\\n\");\n\nvar list_points = []\n\nvar arrayLength = lines.length;\nfor (var i = 0; i < arrayLength; i++) {\n\tline = JSON.parse(lines[i])\n\t\n\tout = line.split(\",\");\n name_value = out[0].substring(9,14)\n lat_value = out[1].substring(7,17)\n lon_value = out[2].substring(6,14)\n\n\nvar dict_point = {\n name: name_value,\n lat: lat_value,\n lon: lon_value,\n icon : \":diamonds:\",\n\n};\nlist_points.push(dict_point)\n}\n\nmsg.payload = list_points;\n\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 740,
"y": 1300,
"wires": [
[
"a6bd82958e8706b1",
"e5671c6fbb83163d"
]
]
},
{
"id": "a6bd82958e8706b1",
"type": "ui_worldmap",
"z": "b423c3276f31428e",
"group": "160e81fb.f1c86e",
"order": 10,
"width": 18,
"height": 9,
"name": "",
"lat": "",
"lon": "",
"zoom": "18",
"layer": "OSMC",
"cluster": "17",
"maxage": "",
"usermenu": "show",
"layers": "hide",
"panit": "true",
"panlock": "false",
"zoomlock": "false",
"hiderightclick": "false",
"coords": "deg",
"showgrid": "true",
"allowFileDrop": "false",
"path": "/worldmap3",
"overlist": "DR,CO,RA,DN,HM",
"maplist": "OSMG,OSMC,EsriC,EsriS,EsriT,EsriO,EsriDG,NatGeo,UKOS,OpTop,SW",
"mapname": "",
"mapurl": "",
"mapopt": "",
"mapwms": false,
"x": 950,
"y": 1300,
"wires": []
},
{
"id": "e5671c6fbb83163d",
"type": "debug",
"z": "b423c3276f31428e",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 870,
"y": 1220,
"wires": []
},
{
"id": "491e65281f27f4d8",
"type": "json",
"z": "b423c3276f31428e",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 570,
"y": 1380,
"wires": [
[
"3113ccc41272a67f",
"d701d7d889e4b605"
]
]
},
{
"id": "160e81fb.f1c86e",
"type": "ui_group",
"name": "Download / Plot",
"tab": "b63d1f91.68095",
"order": 1,
"disp": true,
"width": "18",
"collapse": false,
"className": ""
},
{
"id": "b63d1f91.68095",
"type": "ui_tab",
"name": "File Download",
"icon": "fa-download",
"order": 4,
"disabled": false,
"hidden": false
}
]
Maybe my function is not correct or I am thinking the wrong way.
Another question would be, if there is a maximum for input arguments for the worldmap?
Thanks in advance!!