Function with two Inputs to one Output

Hi,
i have a flow and need help with a function.
I have two msg.payload as Input.
In this function should be converted to msg.payload.lat and the other to msg.payload.lon

Can me help someone?

Thanks

[
    {
        "id": "c6f220e14ed5db21",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "1ef84508e36156e5",
        "type": "string",
        "z": "c6f220e14ed5db21",
        "name": "",
        "methods": [
            {
                "name": "left",
                "params": [
                    {
                        "type": "num",
                        "value": "10"
                    }
                ]
            }
        ],
        "prop": "payload",
        "propout": "payload",
        "object": "msg",
        "objectout": "msg",
        "x": 990,
        "y": 320,
        "wires": [
            [
                "42514e6f1ba652d3"
            ]
        ]
    },
    {
        "id": "c57fd874b886502a",
        "type": "inject",
        "z": "c6f220e14ed5db21",
        "name": "Test",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "10",
        "topic": "",
        "payload": "7.12345000 50.43209000",
        "payloadType": "str",
        "x": 830,
        "y": 360,
        "wires": [
            [
                "1ef84508e36156e5",
                "8d8456b9327f450f"
            ]
        ]
    },
    {
        "id": "8d8456b9327f450f",
        "type": "string",
        "z": "c6f220e14ed5db21",
        "name": "",
        "methods": [
            {
                "name": "right",
                "params": [
                    {
                        "type": "num",
                        "value": "11"
                    }
                ]
            }
        ],
        "prop": "payload",
        "propout": "payload",
        "object": "msg",
        "objectout": "msg",
        "x": 990,
        "y": 400,
        "wires": [
            [
                "24340e2ea9a25ba0"
            ]
        ]
    },
    {
        "id": "42514e6f1ba652d3",
        "type": "convert",
        "z": "c6f220e14ed5db21",
        "name": "",
        "convertTo": "number",
        "x": 1230,
        "y": 320,
        "wires": [
            [
                "d50579ee36a1b74e",
                "69ce2d6eeada3c4c"
            ]
        ]
    },
    {
        "id": "24340e2ea9a25ba0",
        "type": "convert",
        "z": "c6f220e14ed5db21",
        "name": "",
        "convertTo": "number",
        "x": 1230,
        "y": 400,
        "wires": [
            [
                "9216946889be3c79",
                "69ce2d6eeada3c4c"
            ]
        ]
    },
    {
        "id": "d50579ee36a1b74e",
        "type": "debug",
        "z": "c6f220e14ed5db21",
        "name": "debug 2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1400,
        "y": 260,
        "wires": []
    },
    {
        "id": "9216946889be3c79",
        "type": "debug",
        "z": "c6f220e14ed5db21",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1400,
        "y": 460,
        "wires": []
    },
    {
        "id": "747b0e5b64b8a97e",
        "type": "debug",
        "z": "c6f220e14ed5db21",
        "name": "debug 6",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.lat",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1680,
        "y": 320,
        "wires": []
    },
    {
        "id": "69ce2d6eeada3c4c",
        "type": "function",
        "z": "c6f220e14ed5db21",
        "name": "function 2",
        "func": "\nvar lat;\nvar lon;\n\n//msg.payload = { \"name\": \"Worldmap\", \"lat\": lat, \"lon\": lon }\n\n\nmsg.payload = { \"name\":\"Worldmap\", \"lat\":51.05, \"lon\":-1.35 }\n\nreturn msg;\n\n\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1480,
        "y": 360,
        "wires": [
            [
                "747b0e5b64b8a97e",
                "d47a069cb4b5aa48"
            ]
        ]
    },
    {
        "id": "d47a069cb4b5aa48",
        "type": "debug",
        "z": "c6f220e14ed5db21",
        "name": "debug 7",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.lon",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1680,
        "y": 400,
        "wires": []
    }
]

Messages are processed by the function node one at a time. So you need to add a join node before the function node to combine the two messages into one msg being sent to the function node.

Is the data coming from two inputs? If not, why not start by putting the lat and lon in one msg?

This question crops-up quite often.
There is an article in the Cookbook about the 'join' node (that @zenofmud mentioned using).
https://cookbook.nodered.org/basic/join-streams

Looking at your flow, it appears that the lat and lon are originating in one message. If that is the case then don't split it into two messages, keep it in one.

Something like this should do it, fed directly from the inject node

// split the input string into two array elements
const split = msg.payload.split(' ')
msg.payload = { "name":"Worldmap", "lat":Number(split[1]), "lon":Number(split[0])}
return msg;