A Flight Control System to move icon in World Map

I want to do something like this:

let move = flow.get("location") || set_it;
let bearing = move.bearing;

then change the values to N, S, E and W depending on the bearing of the marker, but it gives me the error: "Cannot read property 'bearing' of undefined", which I cannot seem to understand as why this is happening when bearing is already defined by this statement:

let bearing = move.bearing:

I see you added node.warn's in but you didn't identify them so you don't know which is which.
Change them to someting like
node.warn("in down if - bearing=" + bearing)

Being it is close to Christmas and I'm about to have two small sick children arrive I'll tell you part of your issue. In each of the IF routines you end with a return msg; which ends the function node.

so your last bit of code

move.bearing = bearing;
flow.set("location", move);
return msg;

never gets run.

Changed as per your suggestion, but this error will make me loose my job.

var R = 6378.1; // Radius of Earth
var dist = 100; // Distance in meters
var theta = (dist / R) * 2 * Math.PI; // Angular distance in radians
var speed = 0;

var lat1 = 0.0;
var lon1 = 0.0;

var lat2 = flow.get("lat2") || 0;
var lon2 = flow.get("lon2") || 0;

if(msg.topic == "lat"){
    lat2 = msg.payload; 
    flow.set("lat2", lat2);
    return msg;
}

if(msg.topic == "lon"){
    lon2 = msg.payload ;
    flow.set("lon2", lon2);
    return msg;
}

var y = Math.sin(lon2 - lon1) * Math.cos(lat2);
var x = Math.cos(lat1)*Math.sin(lat2) - Math.sin(lat1)*Math.cos(lat2)*Math.cos(lon2-lon1);
var angle = Math.atan2(y, x);
var brng = (angle*180/Math.PI + 360) % 360; // in degrees

if(msg.topic == "set"){
    var set_it = {
        name:"SIMULU",
        lat: lat2,
        lon: lon2,
        icon: "plane",
        iconColor: "black",
        layer: "gps",
        bearing: brng,
        speed: speed + "kn",
        popped: true
    }
    msg.payload = set_it;
    return msg;
}

var lat3 = Math.asin(Math.sin(lat1) * Math.cos(theta) +
            Math.cos(lat1) * Math.sin(theta) * Math.cos(brng));

var lon3 = lon1 + Math.atan2(Math.sin(brng) * Math.sin(theta)* Math.cos(lat1),
            Math.cos(theta) - Math.sin(lat1) * Math.sin(lat3))

var lat3_deg = lat3 * 180 / Math.PI;
var lon3_deg = lon3 * 180 / Math.PI;

let move = flow.get("location") || set_it ;
let bearing = move.bearing; 

if(msg.topic == "up"){
    if(bearing == 0){
        bearing = 0;
    }
    var up = {
        name:"SIMULU",
        bearing:bearing,
        layer:"gps",
        popped:true
    }
    node.warn("Up-bearing=" +bearing);
    msg.payload = up;
}

if(msg.topic=="right"){
    if(bearing >= 0 || bearing < 90){
        bearing = 90;
    }
    var right = {
        name:"SIMULU",
        bearing:bearing,
        layer:"gps",
        popped:true
    }
    node.warn("Right-bearing=" +bearing)
    msg.payload = right;
}

if(msg.topic == "down"){
    if(bearing > 90 || bearing < 270){
        bearing = 180;
    }
    var down = {
        name: "SIMULU",
        bearing:bearing,
        layer:"gps",
        popped:true
    }
    node.warn("Down-bearing=" +bearing)
    msg.payload = down;
}

if(msg.topic=="left"){
    if(bearing > 180 || bearing < 360 ){
        bearing = 270;
    }
    var left = {
        name:"SIMULU",
        bearing:bearing,
        layer:"gps",
        popped:true
    }
    node.warn("Left-bearing=" +bearing)
    msg.payload = left;
}

move.bearing = bearing;
flow.set("location", move);
return msg;

Solved.
This is my current flow:

[
    {
        "id": "01732bfeeaa6afce",
        "type": "ui_text_input",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "label": "Initial Lat Position",
        "tooltip": "",
        "group": "b4ebae93d455bbc5",
        "order": 2,
        "width": 6,
        "height": 1,
        "passthru": true,
        "mode": "number",
        "delay": "100",
        "topic": "lat",
        "sendOnBlur": true,
        "className": "",
        "topicType": "str",
        "x": 230,
        "y": 420,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "2aeed1b10c6c1515",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 3,
        "width": 2,
        "height": 1,
        "passthru": false,
        "label": "Set",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "set",
        "topicType": "str",
        "x": 390,
        "y": 580,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "2cb3acd121995f56",
        "type": "worldmap-tracks",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "depth": 20,
        "layer": "single",
        "smooth": false,
        "x": 790,
        "y": 400,
        "wires": [
            [
                "14927396080798d3"
            ]
        ]
    },
    {
        "id": "14927396080798d3",
        "type": "worldmap",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "lat": "48.80",
        "lon": "13.50",
        "zoom": "",
        "layer": "OSMC",
        "cluster": "",
        "maxage": "20",
        "usermenu": "show",
        "layers": "show",
        "panit": "true",
        "panlock": "false",
        "zoomlock": "false",
        "hiderightclick": "false",
        "coords": "deg",
        "showgrid": "false",
        "showruler": "false",
        "allowFileDrop": "false",
        "path": "/worldmap",
        "overlist": "DR,CO,RA,DN,AC,HM",
        "maplist": "OSMG,OSMC,EsriC,EsriS,EsriT,EsriDG,UKOS",
        "mapname": "",
        "mapurl": "",
        "mapopt": "",
        "mapwms": false,
        "x": 1020,
        "y": 460,
        "wires": []
    },
    {
        "id": "3f1eed7c26c68aa2",
        "type": "ui_text_input",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "label": "Initial Lon Position",
        "tooltip": "",
        "group": "b4ebae93d455bbc5",
        "order": 4,
        "width": 6,
        "height": 1,
        "passthru": true,
        "mode": "number",
        "delay": "100",
        "topic": "lon",
        "sendOnBlur": true,
        "className": "",
        "topicType": "str",
        "x": 230,
        "y": 460,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "bd958146f73af5c1",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 11,
        "width": 6,
        "height": 1,
        "passthru": false,
        "label": "up",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "up",
        "topicType": "str",
        "x": 210,
        "y": 340,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "83cee2bda843d0d2",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 13,
        "width": 6,
        "height": 1,
        "passthru": false,
        "label": "down",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "down",
        "topicType": "str",
        "x": 190,
        "y": 520,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "03aa2f6ba41795a5",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 15,
        "width": 6,
        "height": 1,
        "passthru": false,
        "label": "left",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "left",
        "topicType": "str",
        "x": 190,
        "y": 560,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "7347a00f5de4aab0",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 17,
        "width": 6,
        "height": 1,
        "passthru": false,
        "label": "right",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "right",
        "topicType": "str",
        "x": 210,
        "y": 380,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "fa8d16f8a3e226de",
        "type": "function",
        "z": "594f4d4bfd9f7699",
        "name": "function 3",
        "func": "var R = 6378.1; // Radius of Earth\nvar dist = 100; // Distance in meters\nvar theta = (dist / R) * 2 * Math.PI; // Angular distance in radians\nvar speed = 0;\n\nvar lat1 = 0.0;\nvar lon1 = 0.0;\n\nvar lat2 = flow.get(\"lat2\") || 0;\nvar lon2 = flow.get(\"lon2\") || 0;\n\nif(msg.topic == \"lat\"){\n    lat2 = msg.payload; \n    flow.set(\"lat2\", lat2);\n    return msg;\n}\n\nif(msg.topic == \"lon\"){\n    lon2 = msg.payload ;\n    flow.set(\"lon2\", lon2);\n    return msg;\n}\n\nvar y = Math.sin(lon2 - lon1) * Math.cos(lat2);\nvar x = Math.cos(lat1)*Math.sin(lat2) - Math.sin(lat1)*Math.cos(lat2)*Math.cos(lon2-lon1);\nvar angle = Math.atan2(y, x);\nvar brng = (angle*180/Math.PI + 360) % 360; // in degrees\n\nif(msg.topic == \"set\"){\n    var set_it = {\n        name:\"SIMULU\",\n        lat: lat2,\n        lon: lon2,\n        icon: \"plane\",\n        iconColor: \"black\",\n        layer: \"gps\",\n        bearing: brng,\n        speed: speed + \"kn\",\n        popped: true\n    }\n    msg.payload = set_it;\n}\n\nvar lat3 = Math.asin(Math.sin(lat1) * Math.cos(theta) +\n            Math.cos(lat1) * Math.sin(theta) * Math.cos(brng));\n\nvar lon3 = lon1 + Math.atan2(Math.sin(brng) * Math.sin(theta)* Math.cos(lat1),\n            Math.cos(theta) - Math.sin(lat1) * Math.sin(lat3))\n\nvar lat3_deg = lat3 * 180 / Math.PI;\nvar lon3_deg = lon3 * 180 / Math.PI;\n\nlet move = flow.get(\"location\") || set_it ;\nlet bearing = move.bearing; \n\nif(msg.topic == \"up\"){\n    if(bearing = 0){\n        bearing = 0;\n    }\n    var up = {\n        name:\"SIMULU\",\n        bearing:bearing,\n        layer:\"gps\",\n        popped:true\n    }\n    node.warn(\"Up-bearing=\" +bearing);\n    msg.payload = up;\n}\n\nif(msg.topic==\"right\"){\n    if(bearing >= 0 || bearing < 90){\n        bearing = 90;\n    }\n    var right = {\n        name:\"SIMULU\",\n        bearing:bearing,\n        layer:\"gps\",\n        popped:true\n    }\n    node.warn(\"Right-bearing=\" +bearing)\n    msg.payload = right;\n}\n\nif(msg.topic == \"down\"){\n    if(bearing > 90 || bearing < 270){\n        bearing = 180;\n    }\n    var down = {\n        name: \"SIMULU\",\n        bearing:bearing,\n        layer:\"gps\",\n        popped:true\n    }\n    node.warn(\"Down-bearing=\" +bearing)\n    msg.payload = down;\n}\n\nif(msg.topic==\"left\"){\n    if(bearing > 180 || bearing < 360 ){\n        bearing = 270;\n    }\n    var left = {\n        name:\"SIMULU\",\n        bearing:bearing,\n        layer:\"gps\",\n        popped:true\n    }\n    node.warn(\"Left-bearing=\" +bearing)\n    msg.payload = left;\n}\n\nmove.bearing = bearing;\nflow.set(\"location\", move);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 560,
        "y": 420,
        "wires": [
            [
                "9336120dc02d8212",
                "2cb3acd121995f56",
                "14927396080798d3"
            ]
        ]
    },
    {
        "id": "9336120dc02d8212",
        "type": "debug",
        "z": "594f4d4bfd9f7699",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 580,
        "wires": []
    },
    {
        "id": "b4ebae93d455bbc5",
        "type": "ui_group",
        "name": "UAV Flight Control",
        "tab": "37a720198b072daf",
        "order": 1,
        "disp": true,
        "width": "17",
        "collapse": false,
        "className": ""
    },
    {
        "id": "37a720198b072daf",
        "type": "ui_tab",
        "name": "Flight_Control",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]
1 Like

Good work, so can we close this thread?

I guess, I might need some more suggestions/ideas with the flow itself, so let it be open for 1-2 weeks more.

As a holiday present here is a small flow you should look at. It adds a plane icon to the world map using an object and stores the object in a flow variable. There is a joy stick that only moves on the horizontal axis. The joystick changes the direction of the plane.

[{"id":"ec9da974.051b48","type":"inject","z":"0cf5468e4f10f4ff","name":"","repeat":"","crontab":"","once":false,"topic":"","payload":"","payloadType":"str","x":530,"y":880,"wires":[["f77a7ed4.f955d"]]},{"id":"f77a7ed4.f955d","type":"function","z":"0cf5468e4f10f4ff","name":"Add plane to map","func":"let thing = {\n    name: \"UAV\",\n    lat: 51,\n    lon: -1.45,\n    heading: 0,\n    icon: \"plane\",\n    iconColor: \"darkred\",\n    extrainfo: \"UAV testing\"\n};\nlet uav = flow.get(\"UAV\") || thing\n\nflow.set(\"UAV\",uav)\nmsg.payload = uav;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":880,"wires":[["f83930ff.b21488"]]},{"id":"cd09f7be.079518","type":"comment","z":"0cf5468e4f10f4ff","name":"Simple map - joystick changes plane direction","info":"Adds a map at http://(your-server-ip):1880/worldmap2. \n\nThe `function` node creates an object with some basic properties required to add to a map.","x":590,"y":820,"wires":[]},{"id":"f83930ff.b21488","type":"worldmap","z":"0cf5468e4f10f4ff","name":"","lat":"","lon":"","zoom":"","layer":"OSMG","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"false","panlock":"false","zoomlock":"false","hiderightclick":"false","coords":"none","showgrid":"false","allowFileDrop":"false","path":"/worldmap2","overlist":"DR,CO,RA,DN,HM","maplist":"OSMG,OSMC,EsriC,EsriS,EsriT,EsriO,EsriDG,NatGeo,UKOS,OpTop","mapname":"","mapurl":"","mapopt":"","mapwms":false,"x":1030,"y":920,"wires":[]},{"id":"18f32546d94e502a","type":"function","z":"0cf5468e4f10f4ff","name":"update plane on map","func":"let thing = {\n    name:\"UAV\", \n    lat:51, \n    lon:-1.45,\n    heading: 0,\n    icon: \"plane\",\n    iconColor:\"darkred\",\n    extrainfo:\"UAV testing\"\n};\nlet uav = flow.get(\"UAV\") || thing\n\nif (msg.payload == 'right'){\n    uav.heading = uav.heading + 5\n    if (uav.heading >359) {\n        uav.heading = uav.heading - 360\n    }\n} else if (msg.payload == 'left') {\n    uav.heading = uav.heading - 5\n    if (uav.heading < 0) {\n        uav.heading = 360 - uav.heading \n    }\n}\n//uav.heading =  msg.payload\nflow.set(\"UAV\",uav)\nmsg.payload = uav;\nnode.warn(uav)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":960,"wires":[["f83930ff.b21488","084e2f15a31cf0c3"]]},{"id":"eb405146caa6e987","type":"debug","z":"0cf5468e4f10f4ff","name":"debug 140","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":490,"y":1020,"wires":[]},{"id":"ad6683e41070be2b","type":"ui_joystick","z":"0cf5468e4f10f4ff","name":"","group":"b4ebae93d455bbc5","order":26,"width":3,"height":3,"trigger":"all","timeInterval":"25","useThemeColor":true,"color":"#000000","threshold":0.1,"directions":"hor","shape":"circle","centerAtRelease":true,"x":150,"y":960,"wires":[["b878793f8dcb889c","753bb6cb67f84f90"]]},{"id":"9848ea49f77a2aa9","type":"change","z":"0cf5468e4f10f4ff","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.direction.x","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":960,"wires":[["18f32546d94e502a","eb405146caa6e987"]]},{"id":"084e2f15a31cf0c3","type":"debug","z":"0cf5468e4f10f4ff","name":"debug 141","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":730,"y":1020,"wires":[]},{"id":"b878793f8dcb889c","type":"debug","z":"0cf5468e4f10f4ff","name":"debug 142","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":170,"y":1020,"wires":[]},{"id":"753bb6cb67f84f90","type":"rbe","z":"0cf5468e4f10f4ff","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":330,"y":960,"wires":[["9848ea49f77a2aa9"]]},{"id":"b4ebae93d455bbc5","type":"ui_group","name":"UAV Flight Control","tab":"37a720198b072daf","order":1,"disp":true,"width":"17","collapse":false,"className":""},{"id":"37a720198b072daf","type":"ui_tab","name":"Flight_Control","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

The idea is to have one object that is always sent to the world map. You could then have power slider that would control the movement of the plane - you would need to calculate the new location of the plane as long as power is applied. (in real live if you shut off power there would still be movement until drag blead the speed from the object)

Have fun and a happy holiday.

1 Like

(Sorry) This might be a bit off-topic on what you are trying to achieve. Here's a link to a tutorial I wrote( just over 3-years ago) for my IoT students to track aircraft movements using FlightRadar24.

Thank you for the present I will surely play with it and look for more ideas in it. Maybe a last question before holidays, my current flow is as below. In the flow, the initial value given by user is set and then when we press any button the icon moves in that direction that works fine. When again if we set new lat and lon values the marker is shown on that position but as soon as we press any of the buttons, the marker returns to its last value of that button, I want to add the functionality that if a new position is set, the marker should move from that position when the buttons are pressed and not from the previous position? I know this is a very childish question but any suggestions/ideas to that?

[
    {
        "id": "01732bfeeaa6afce",
        "type": "ui_text_input",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "label": "Initial Lat Position",
        "tooltip": "",
        "group": "b4ebae93d455bbc5",
        "order": 2,
        "width": 6,
        "height": 1,
        "passthru": true,
        "mode": "number",
        "delay": "100",
        "topic": "lat",
        "sendOnBlur": true,
        "className": "",
        "topicType": "str",
        "x": 230,
        "y": 420,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "2aeed1b10c6c1515",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 3,
        "width": 2,
        "height": 1,
        "passthru": false,
        "label": "Set",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "set",
        "topicType": "str",
        "x": 390,
        "y": 580,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "2cb3acd121995f56",
        "type": "worldmap-tracks",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "depth": 20,
        "layer": "single",
        "smooth": false,
        "x": 790,
        "y": 400,
        "wires": [
            [
                "14927396080798d3"
            ]
        ]
    },
    {
        "id": "14927396080798d3",
        "type": "worldmap",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "lat": "48.80",
        "lon": "13.50",
        "zoom": "",
        "layer": "OSMC",
        "cluster": "",
        "maxage": "20",
        "usermenu": "show",
        "layers": "show",
        "panit": "true",
        "panlock": "false",
        "zoomlock": "false",
        "hiderightclick": "false",
        "coords": "deg",
        "showgrid": "false",
        "showruler": "false",
        "allowFileDrop": "false",
        "path": "/worldmap",
        "overlist": "DR,CO,RA,DN,AC,HM",
        "maplist": "OSMG,OSMC,EsriC,EsriS,EsriT,EsriDG,UKOS",
        "mapname": "",
        "mapurl": "",
        "mapopt": "",
        "mapwms": false,
        "x": 1020,
        "y": 460,
        "wires": []
    },
    {
        "id": "3f1eed7c26c68aa2",
        "type": "ui_text_input",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "label": "Initial Lon Position",
        "tooltip": "",
        "group": "b4ebae93d455bbc5",
        "order": 4,
        "width": 6,
        "height": 1,
        "passthru": true,
        "mode": "number",
        "delay": "100",
        "topic": "lon",
        "sendOnBlur": true,
        "className": "",
        "topicType": "str",
        "x": 230,
        "y": 460,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "bd958146f73af5c1",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 11,
        "width": 6,
        "height": 1,
        "passthru": false,
        "label": "up",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "up",
        "topicType": "str",
        "x": 210,
        "y": 340,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "83cee2bda843d0d2",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 13,
        "width": 6,
        "height": 1,
        "passthru": false,
        "label": "down",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "down",
        "topicType": "str",
        "x": 190,
        "y": 520,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "03aa2f6ba41795a5",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 15,
        "width": 6,
        "height": 1,
        "passthru": false,
        "label": "left",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "left",
        "topicType": "str",
        "x": 190,
        "y": 560,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "7347a00f5de4aab0",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 17,
        "width": 6,
        "height": 1,
        "passthru": false,
        "label": "right",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "right",
        "topicType": "str",
        "x": 210,
        "y": 380,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "fa8d16f8a3e226de",
        "type": "function",
        "z": "594f4d4bfd9f7699",
        "name": "function 3",
        "func": "var R = 6378.1; // Radius of Earth\nvar dist = 100; // Distance in meters\nvar theta = (dist / R) * 2 * Math.PI; // Angular distance in radians\nvar speed = 0;\n\nvar lat1 = 0.0;\nvar lon1 = 0.0;\n\nvar lat2 = flow.get(\"lat2\") || 0;\nvar lon2 = flow.get(\"lon2\") || 0;\n\nif(msg.topic == \"lat\"){\n    lat2 = msg.payload; \n    flow.set(\"lat2\", lat2);\n    \n}\n\nif(msg.topic == \"lon\"){\n    lon2 = msg.payload ;\n    flow.set(\"lon2\", lon2);\n    \n}\n\nvar y = Math.sin(lon2 - lon1) * Math.cos(lat2);\nvar x = Math.cos(lat1)*Math.sin(lat2) - Math.sin(lat1)*Math.cos(lat2)*Math.cos(lon2-lon1);\nvar angle = Math.atan2(y, x);\nvar brng = (angle*180/Math.PI + 360) % 360; // in degrees\n\nif(msg.topic == \"set\"){\n    var set_it = {\n        name:\"SIMULU\",\n        lat: lat2,\n        lon: lon2,\n        icon: \"plane\",\n        iconColor: \"black\",\n        layer: \"gps\",\n        bearing: brng,\n        speed: speed + \"kn\",\n        popped: true\n    }\n    msg.payload = set_it;\n}\n\nvar lat3 = Math.asin(Math.sin(lat1) * Math.cos(theta) +\n            Math.cos(lat1) * Math.sin(theta) * Math.cos(brng));\n\nvar lon3 = lon1 + Math.atan2(Math.sin(brng) * Math.sin(theta)* Math.cos(lat1),\n            Math.cos(theta) - Math.sin(lat1) * Math.sin(lat3))\n\nvar lat3_deg = lat3 * 180 / Math.PI;\nvar lon3_deg = lon3 * 180 / Math.PI;\n\nlet move = flow.get(\"location\") || set_it ;\nlet bearing = move.bearing;\nlet lat = move.lat;\nlet lon = move.lon;\n\nif(msg.topic == \"up\"){\n    if(bearing = 0){\n        bearing = 0;\n    }\n    move.lat = move.lat + 0.01;\n    move.lon = move.lon + 0; \n    var up = {\n        name:\"SIMULU\",\n        lat: move.lat,\n        lon: move.lon,\n        bearing:bearing,\n        layer:\"gps\",\n        popped:true\n    }\n    node.warn(\"Up-bearing=\" +bearing);\n    msg.payload = up;\n}\n\nif(msg.topic==\"right\"){\n    if(bearing >= 0 || bearing < 90){\n        bearing = 90;\n    }\n    move.lat = move.lat + 0;\n    move.lon = move.lon + 0.01;\n    var right = {\n        name:\"SIMULU\",\n        lat: move.lat,\n        lon: move.lon,\n        bearing:bearing,\n        layer:\"gps\",\n        popped:true\n    }\n    node.warn(\"Right-bearing=\" +bearing)\n    msg.payload = right;\n}\n\nif(msg.topic == \"down\"){\n    if(bearing > 90 || bearing < 270){\n        bearing = 180;\n    }\n    move.lat = move.lat - 0.01;\n    move.lon = move.lon  - 0;\n    var down = {\n        name: \"SIMULU\",\n        lat: move.lat,\n        lon: move.lon,\n        bearing:bearing,\n        layer:\"gps\",\n        popped:true\n    }\n    node.warn(\"Down-bearing=\" +bearing)\n    msg.payload = down;\n}\n\nif(msg.topic==\"left\"){\n    if(bearing > 180 || bearing < 360 ){\n        bearing = 270;\n    }\n    move.lat = move.lat - 0;\n    move.lon = move.lon - 0.01;\n    var left = {\n        name:\"SIMULU\",\n        lat: move.lat,\n        lon: move.lon,\n        bearing:bearing,\n        layer:\"gps\",\n        popped:true\n    }\n    node.warn(\"Left-bearing=\" +bearing)\n    msg.payload = left;\n}\n\nmove.bearing = bearing;\nflow.set(\"location\", move);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 560,
        "y": 420,
        "wires": [
            [
                "9336120dc02d8212",
                "2cb3acd121995f56",
                "14927396080798d3"
            ]
        ]
    },
    {
        "id": "9336120dc02d8212",
        "type": "debug",
        "z": "594f4d4bfd9f7699",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 580,
        "wires": []
    },
    {
        "id": "b4ebae93d455bbc5",
        "type": "ui_group",
        "name": "UAV Flight Control",
        "tab": "37a720198b072daf",
        "order": 1,
        "disp": true,
        "width": "17",
        "collapse": false,
        "className": ""
    },
    {
        "id": "37a720198b072daf",
        "type": "ui_tab",
        "name": "Flight_Control",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

I would create a new flow variable object with the new location and have the set button create that object. Then you could compare the current location with the new location and start updating the current location (a little bit at a time) and sent it to the map. This would go on until the current location matches the new location

Hello @zenofmud,
I hope you are good and your holidays went well too. I tried to implement your idea but I cannot get a work around to that. I am still stuck at the last flow I posted and my queries are still there. I want to add a speed slider which when prompted should take the marker from initial position to the next position slowly and also the buttons up, down, right and left store the initial values which are prompted at the start of Node-Red and work with the stored value but when a new value is initialized by the set button and again button are pressed to work with this position the marker returns to the already stored value at the start. I don't know where I am doing wrong.

Hi, sorry I havenā€™t replied. I had a mess with updating the system on my computer and most of my efforts the past two weeks have been recovering data. And the past two days we had our roof re-roofed and my office is just under the roof. Too loud to even think about working in it. Send my your current flow and Iā€™ll try to take a look but Iā€™m babysitting our 2 yr old granddaughter tomorrow so I wonā€™t get much done at all.

Hi @zenofmud,
I have been active for a week. Apologies for late reply. Here is my current flow:

[
    {
        "id": "594f4d4bfd9f7699",
        "type": "tab",
        "label": "Flight_Control_SIMULU",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "319ff3a15befbaa7",
        "type": "ui_worldmap",
        "z": "594f4d4bfd9f7699",
        "group": "b4ebae93d455bbc5",
        "order": 1,
        "width": 9,
        "height": 10,
        "name": "",
        "lat": "48.80",
        "lon": "13.50",
        "zoom": "",
        "layer": "OSMC",
        "cluster": "0",
        "maxage": "",
        "usermenu": "hide",
        "layers": "hide",
        "panit": "true",
        "panlock": "false",
        "zoomlock": "false",
        "hiderightclick": "true",
        "coords": "deg",
        "showgrid": "false",
        "showruler": "false",
        "allowFileDrop": "false",
        "path": "/worldmap",
        "overlist": "DR,CO,RA,DN,AC,HM",
        "maplist": "OSMG,OSMC,EsriC,EsriS,EsriT,EsriDG,UKOS",
        "mapname": "",
        "mapurl": "",
        "mapopt": "",
        "mapwms": false,
        "x": 1100,
        "y": 40,
        "wires": []
    },
    {
        "id": "01732bfeeaa6afce",
        "type": "ui_text_input",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "label": "Initial Lat Position",
        "tooltip": "",
        "group": "b4ebae93d455bbc5",
        "order": 2,
        "width": 6,
        "height": 1,
        "passthru": true,
        "mode": "number",
        "delay": "100",
        "topic": "lat",
        "sendOnBlur": true,
        "className": "",
        "topicType": "str",
        "x": 150,
        "y": 160,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "2aeed1b10c6c1515",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 3,
        "width": 2,
        "height": 1,
        "passthru": false,
        "label": "Set",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "set",
        "topicType": "str",
        "x": 330,
        "y": 40,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "2cb3acd121995f56",
        "type": "worldmap-tracks",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "depth": 20,
        "layer": "single",
        "smooth": false,
        "x": 710,
        "y": 140,
        "wires": [
            [
                "14927396080798d3"
            ]
        ]
    },
    {
        "id": "14927396080798d3",
        "type": "worldmap",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "lat": "48.80",
        "lon": "13.50",
        "zoom": "",
        "layer": "OSMC",
        "cluster": "",
        "maxage": "20",
        "usermenu": "show",
        "layers": "show",
        "panit": "true",
        "panlock": "false",
        "zoomlock": "false",
        "hiderightclick": "false",
        "coords": "deg",
        "showgrid": "false",
        "showruler": "false",
        "allowFileDrop": "false",
        "path": "/worldmap",
        "overlist": "DR,CO,RA,DN,AC,HM",
        "maplist": "OSMG,OSMC,EsriC,EsriS,EsriT,EsriDG,UKOS",
        "mapname": "",
        "mapurl": "",
        "mapopt": "",
        "mapwms": false,
        "x": 940,
        "y": 200,
        "wires": []
    },
    {
        "id": "3f1eed7c26c68aa2",
        "type": "ui_text_input",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "label": "Initial Lon Position",
        "tooltip": "",
        "group": "b4ebae93d455bbc5",
        "order": 4,
        "width": 6,
        "height": 1,
        "passthru": true,
        "mode": "number",
        "delay": "100",
        "topic": "lon",
        "sendOnBlur": true,
        "className": "",
        "topicType": "str",
        "x": 150,
        "y": 200,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "bd958146f73af5c1",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 12,
        "width": 6,
        "height": 1,
        "passthru": false,
        "label": "up",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "up",
        "topicType": "str",
        "x": 130,
        "y": 60,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "83cee2bda843d0d2",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 14,
        "width": 6,
        "height": 1,
        "passthru": false,
        "label": "down",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "down",
        "topicType": "str",
        "x": 110,
        "y": 260,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "03aa2f6ba41795a5",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 16,
        "width": 6,
        "height": 1,
        "passthru": false,
        "label": "left",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "left",
        "topicType": "str",
        "x": 110,
        "y": 300,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "7347a00f5de4aab0",
        "type": "ui_button",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "group": "b4ebae93d455bbc5",
        "order": 18,
        "width": 6,
        "height": 1,
        "passthru": false,
        "label": "right",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "right",
        "topicType": "str",
        "x": 130,
        "y": 120,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "fa8d16f8a3e226de",
        "type": "function",
        "z": "594f4d4bfd9f7699",
        "name": "function 3",
        "func": "var R = 6378.1; // Radius of Earth\nvar dist = 100; // Distance in meters\nvar theta = (dist / R) * 2 * Math.PI; // Angular distance in radians\nvar speed = 0;\n\nvar lat1 = 0.0;\nvar lon1 = 0.0;\n\nvar lat2 = flow.get(\"lat2\") || 0; //Set Initial Latitude Position\nvar lon2 = flow.get(\"lon2\") || 0; //Set Initial Longitude Position\n\nif(msg.topic == \"lat\"){\n    lat2 = msg.payload; \n    flow.set(\"lat2\", lat2);\n    \n}\n\nif(msg.topic == \"lon\"){\n    lon2 = msg.payload ;\n    flow.set(\"lon2\", lon2);\n    \n}\n\n//Calculate Bearing for Direction\nvar y = Math.sin(lon2 - lon1) * Math.cos(lat2);\nvar x = Math.cos(lat1)*Math.sin(lat2) - Math.sin(lat1)*Math.cos(lat2)*Math.cos(lon2-lon1);\nvar angle = Math.atan2(y, x);\nvar brng = (angle*180/Math.PI + 360) % 360; // in degrees\n\n//Set Position using Set Button\nif(msg.topic == \"set\"){\n    var set_it = {\n        name:\"SIMULU\",\n        lat: lat2,\n        lon: lon2,\n        icon: \"plane\",\n        iconColor: \"black\",\n        layer: \"gps\",\n        bearing: brng,\n        speed: speed + \"kn\",\n        popped: true\n    }\n    msg.payload = set_it;\n}\n\n//Calculation for next point\nvar lat3 = Math.asin(Math.sin(lat1) * Math.cos(theta) +\n            Math.cos(lat1) * Math.sin(theta) * Math.cos(brng));\n\nvar lon3 = lon1 + Math.atan2(Math.sin(brng) * Math.sin(theta)* Math.cos(lat1),\n            Math.cos(theta) - Math.sin(lat1) * Math.sin(lat3))\n\nvar lat3_deg = lat3 * 180 / Math.PI;\nvar lon3_deg = lon3 * 180 / Math.PI;\n\n//Calculation of bearing for next point\nvar y_1 = Math.sin(lon3 - lon2) * Math.cos(lat3);\nvar x_1 = Math.cos(lat2) * Math.sin(lat3) - Math.sin(lat2) * Math.cos(lat3) * Math.cos(lon3 - lon2);\nvar angle = Math.atan2(y_1, x_1);\nvar brng_1 = (angle * 180 / Math.PI + 360) % 360; // in degrees\n\n//Speed slider for next point\nif(msg.topic == \"speed\"){\n    var nxt_pnt = {\n        name: \"SIMULU\",\n        lat: lat3_deg,\n        lon: lon3_deg,\n        bearing: brng_1,\n        layer: \"gps\",\n        popped: true\n    }\n    msg.payload = nxt_pnt;\n}\n\n//Control Buttons for directions\nlet move = flow.get(\"location\") || set_it;\nlet bearing = move.bearing;\nlet lat = move.lat;\nlet lon = move.lon;\n\nif(msg.topic == \"up\"){\n    if(bearing = 0){\n        bearing = 0;\n    }\n    move.lat = move.lat + 0.01;\n    move.lon = move.lon + 0; \n    var up = {\n        name:\"SIMULU\",\n        lat: move.lat,\n        lon: move.lon,\n        bearing:bearing,\n        layer:\"gps\",\n        popped:true\n    }\n    node.warn(\"Up-bearing=\" +bearing);\n    msg.payload = up;\n}\n\nif(msg.topic==\"right\"){\n    if(bearing >= 0 || bearing < 90){\n        bearing = 90;\n    }\n    move.lat = move.lat + 0;\n    move.lon = move.lon + 0.01;\n    var right = {\n        name:\"SIMULU\",\n        lat: move.lat,\n        lon: move.lon,\n        bearing:bearing,\n        layer:\"gps\",\n        popped:true\n    }\n    node.warn(\"Right-bearing=\" +bearing)\n    msg.payload = right;\n}\n\nif(msg.topic == \"down\"){\n    if(bearing > 90 || bearing < 270){\n        bearing = 180;\n    }\n    move.lat = move.lat - 0.01;\n    move.lon = move.lon  - 0;\n    var down = {\n        name: \"SIMULU\",\n        lat: move.lat,\n        lon: move.lon,\n        bearing:bearing,\n        layer:\"gps\",\n        popped:true\n    }\n    node.warn(\"Down-bearing=\" +bearing)\n    msg.payload = down;\n}\n\nif(msg.topic==\"left\"){\n    if(bearing > 180 || bearing < 360 ){\n        bearing = 270;\n    }\n    move.lat = move.lat - 0;\n    move.lon = move.lon - 0.01;\n    var left = {\n        name:\"SIMULU\",\n        lat: move.lat,\n        lon: move.lon,\n        bearing:bearing,\n        layer:\"gps\",\n        popped:true\n    }\n    node.warn(\"Left-bearing=\" +bearing)\n    msg.payload = left;\n}\n\nmove.bearing = bearing;\nflow.set(\"location\", move);\n//msg.payload = move;\n\n/*let new_location = flow.get(\"new_location\") || move;\nlet new_lat = new_location.lat;\nlet new_lon = new_location.lon;\n\n\nif(msg.topic == \"set\"){\n    flow.set(\"new_location\", new_location);\n    node.warn(\"new_location:\" +new_location);\n    msg.payload = new_location;\n}\n*/\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 500,
        "y": 160,
        "wires": [
            [
                "9336120dc02d8212",
                "2cb3acd121995f56",
                "14927396080798d3"
            ]
        ]
    },
    {
        "id": "9336120dc02d8212",
        "type": "debug",
        "z": "594f4d4bfd9f7699",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 800,
        "y": 320,
        "wires": []
    },
    {
        "id": "4293d65595438ef9",
        "type": "ui_slider",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "label": "Speed",
        "tooltip": "",
        "group": "b4ebae93d455bbc5",
        "order": 10,
        "width": 6,
        "height": 1,
        "passthru": true,
        "outs": "end",
        "topic": "speed",
        "topicType": "str",
        "min": 0,
        "max": "100",
        "step": "0.1",
        "className": "",
        "x": 110,
        "y": 360,
        "wires": [
            [
                "68256369fc103b2c"
            ]
        ]
    },
    {
        "id": "68256369fc103b2c",
        "type": "change",
        "z": "594f4d4bfd9f7699",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "speed",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 280,
        "y": 360,
        "wires": [
            [
                "fa8d16f8a3e226de"
            ]
        ]
    },
    {
        "id": "b4ebae93d455bbc5",
        "type": "ui_group",
        "name": "UAV Flight Control",
        "tab": "37a720198b072daf",
        "order": 1,
        "disp": true,
        "width": "17",
        "collapse": false,
        "className": ""
    },
    {
        "id": "37a720198b072daf",
        "type": "ui_tab",
        "name": "Flight_Control",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

Since you have opened another thread asking the same question I'll let others reply and I will close this thread. Also note that this last flow is not the same as the flow in the other thread.