All Collections
User Guides
How to create a real-time map?
How to create a real-time map?

Properly send location data so it can be displayed in Ubidots

David Sepúlveda avatar
Written by David Sepúlveda
Updated over a week ago

Yes! You can use Ubidots to display real-time location of devices. To do so, you need to specify the latitude ("lat") and longitude ("lng") in the "context" of your request. So instead of sending this:


The payload should look like this:



Requests Without Location Data

Typically, this is the payload you send to Ubidots to record sensor data:

Using API Labels

curl -X POST -H "Content-Type: application/json" -d '{"temperature": 20}'{YOUR-TOKEN}

Using Variable IDs

curl -X POST -H "Content-Type: application/json" -d '{"value": "20"}'{YOUR-TOKEN}

These requests will create a single data point in the "Temperature" variable:

Requests With Location Data

If you want to add location data, then you should add a "context" property with these keys:

  • "lat"

  • "lng"

These are case-sensitive! If written differently, the Map widget won't recognize them as location points! Here the above examples but with location data:

Using API Labels

Body of the request: 

{"temperature": {"value":20,"context":{"lat":40.782864,"lng":-73.965355}}}

HTTP Request:

curl -X POST -H "Content-Type: application/json" -d '{"temperature": {"value":20,"context":{"lat":40.782864,"lng":-73.965355}}}'{YOUR-TOKEN}

Using Variable IDs

Body of the request: 


HTTP Request:

curl -X POST -H "Content-Type: application/json" -d '{"value":20,"context":{"lat":40.782864,"lng":-73.965355}}'{YOUR-TOKEN}

Any of these requests will create a data-point with a lat and lng context properties:

Which can be then read by a Map widget. This can be created in your dashboard --> Add new widget --> Map Widget --> Select the device that contains Position (Lat & Long) Properties.

Expectations for Visualization

It is important to note that the Ubidots real-time map display is a live interface. When you select to view a historical range of data in the Map, your historical data will appear as a "trace." Any incoming real-time data will appear as a smooth "line". 

Did this answer your question?