Hi,
My first post/question to the forum.
Main concern:
Why is the tracking line connecting back to the first point?
What I have tried is based on the existing example "Map in Dashboard".
What is intended to achieve is:
- Plot a line track
- At the same time, identify the points along that line track
(Something like connecting the dots, while showing the dots as well)
- Because in the example flow, it is only plotting the lines, but not the in between points.
What I am plotting is from a database.
- One plot is points, in an ascending order
- Second plot is a line track, following the same ascending order
However, the line plot is connecting the first and last points together.
I've uploaded a sample picture and my flow with this post.
- An end result picture
- A picture of some data points from the database
From the flow file (*.json), inside the function node named "map format", there are two (2) objects inside an array that is giving the lat, long coordinates to be plot in the worldmap node.
Hope someone is kind enough to help.
Many thanks.
[{"id":"19751d9.f6c93e2","type":"function","z":"13f47cd8.692c53","name":"select * from","func":"var user = flow.get(\"mapuser\");\n\nmsg.query = \"SELECT * FROM manualtrack_lat_long_time \"+\n\"WHERE time > now()-7d AND \\\"name\\\" = '\"+user+\"'\"\nreturn msg;\n\n//msg.query = 'SELECT tweet,twid,replytoid FROM KKMPutrajaya_tweet '+\n//'WHERE time > now() - 20h AND tweet =~ /Pecahan kes baharu*/'\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":510,"y":200,"wires":[["6672528a.d415dc"]]},{"id":"6672528a.d415dc","type":"influxdb in","z":"13f47cd8.692c53","influxdb":"83631820.58f5f8","name":"","query":"","rawOutput":false,"precision":"","retentionPolicy":"","org":"organisation","x":750,"y":200,"wires":[["7f4af6b9.a56048","d1ab4fb2.87fd6"]]},{"id":"1b1b7ac0.079db5","type":"function","z":"13f47cd8.692c53","name":"map format","func":"var lat = msg.payload.latitude;\nvar lon = msg.payload.longitude;\nvar time = msg.payload.time;\nvar date = time.getDate();\nvar mth = time.getMonth()+1;\n\nvar display = msg.count.toString();\nvar label = msg.count;\nlabel = label.toString();\nlabel = label+ \" (\" +date+ \"-\" +mth+ \" // DD-MM)\"\n\nvar icon = \"car\";\nvar iconColor = \"black\";\nvar color = \"blue\"; //colour of the line \nvar name = msg.payload.user;\n\nvar marker = [{\n lat: lat,\n lon: lon,\n name: label,\n icon: icon,\n iconColor: iconColor,\n color: color,\n label: display\n},\n// Above object is plotting individual points\n// Below object is plotting a track line\n{\n lat: lat,\n lon: lon,\n name: name,\n icon: \"male\",\n iconColor: \"crimson\",\n color: color\n}]\n\nmsg.payload = marker\n\nreturn msg;\n\n/*\nmsg.payload={\n lat:lat,\n lon:lon,\n name:\"Mike\",\n icon:\"car\",\n iconColor: \"Crimson\",\n color:\"#1e90ff\",\n label:\"string of label\",\n radius: 3000\n};\nreturn msg;\n*/\n\n// create random position\n/*\nvar lat = 51 + Math.random() * 0.2;\nvar lon = -1.45 + Math.random() * 0.2;\n*/","outputs":1,"noerr":0,"initialize":"","finalize":"","x":750,"y":280,"wires":[["3db44082.7cf7c","1e6cf272.69492e"]]},{"id":"3db44082.7cf7c","type":"worldmap-tracks","z":"13f47cd8.692c53","name":"","depth":"100","layer":"single","x":910,"y":240,"wires":[["1e6cf272.69492e"]]},{"id":"1e6cf272.69492e","type":"worldmap","z":"13f47cd8.692c53","name":"","lat":"3.1101","lon":"101.6236","zoom":"13","layer":"OSM","cluster":"7","maxage":"","usermenu":"show","layers":"show","panit":"true","panlock":"false","zoomlock":"false","hiderightclick":"false","coords":"none","showgrid":"true","allowFileDrop":"false","path":"/worldmap","x":960,"y":280,"wires":[]},{"id":"7f4af6b9.a56048","type":"split","z":"13f47cd8.692c53","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":510,"y":240,"wires":[["ff6b753c.9b1778"]]},{"id":"ff6b753c.9b1778","type":"counter","z":"13f47cd8.692c53","name":"","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":"1","x":600,"y":280,"wires":[["1b1b7ac0.079db5"]]},{"id":"3b1fd377.4101dc","type":"function","z":"13f47cd8.692c53","name":"reset","func":"msg.reset = \"reset\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":450,"y":280,"wires":[["ff6b753c.9b1778"]]},{"id":"d65bb024.888d","type":"worldmap in","z":"13f47cd8.692c53","name":"","path":"/worldmap","events":"all","x":220,"y":200,"wires":[["f9743628.66d398"]]},{"id":"f9743628.66d398","type":"switch","z":"13f47cd8.692c53","name":"","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"disconnect","vt":"str"},{"t":"eq","v":"connected","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":200,"wires":[["f1f3a9bd.c67c88"],["3b1fd377.4101dc","19751d9.f6c93e2"]]},{"id":"f1f3a9bd.c67c88","type":"function","z":"13f47cd8.692c53","name":"delete context","func":"flow.set(\"mapuser\", undefined)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":520,"y":140,"wires":[[]]},{"id":"d1ab4fb2.87fd6","type":"debug","z":"13f47cd8.692c53","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1010,"y":160,"wires":[]},{"id":"83631820.58f5f8","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"deleteme","name":"","usetls":false,"tls":"","influxdbVersion":"1.x","url":"http://localhost:8086","rejectUnauthorized":true}]