GPS position from Node Red shown on Map Widget

Hi,

I’m sending GPS position from Node Red to Ubidots. But the position don’t show in the Map Widget. How do I get the position into the Map?

The GPS-data comes from Signal K via Node Red to Ubidots, using the Ubidots node.

I appreciate all help!

Regards
Kristian

Hello @kjenset,

I hope this message finds you well.

Here is a complete guide to configure your GPS Position correctly.

One option to achieve that, is to create a single variable called position and sending the respective latitude and longitude into the context of the variable.

So, you need to modify the msg.payload for the following JSON:

msg.payload = {
    position = {
        "value": 1,
        "context": {
            "lat": msg.payload.latitude,
            "lng": msg.payload.longitude
        }
    }
}

Then, you need to change the location of your device for Auto option:

image

I’ll be attentive if you need further assistance.

Alejandro

Hi,

Thanx for your quick respons!
When I use your code I got an error.

Kristian

I apologize, that’s a big error from myself. This is a JSON file, so we need to write “:” instead of “=”.

This is the full correct code.

msg.payload = {
    position: {
        "value": 1,
        "context": {
            "lat": msg.payload.latitude,
            "lng": msg.payload.longitude
        }
    }
}

Now the error is gone, but the payload is not passing the function node.
Any idea?

Kristian

What do you mean about “passing the function node”?

As you can see at the debug, the values from the debug node 5 don’t show, just from the debug node 2. The debug node is atthe front of the function node, and the debug node 5 is after. Also the values don’t been sendt to Ubidots as well.

I guess that we forgot to include the return msg; after the msg.payload object.

msg.payload = {
    position: {
        "value": 1,
        "context": {
            "lat": msg.payload.latitude,
            "lng": msg.payload.longitude
        }
    }
}
return msg;

Now it’s working!!

I’m so happy. If you travel to norway anytime I will buy you a beer! :slight_smile: :grinning:

Regards
Kristian

Jeje, perfect, I will remember that.

Best regards.

Alejandro