Geo cordinates along a map route

Has anyone have a way to get the geo coordinates along a map route so that it can be used within GPS history block. I have heard one can use OpenStreetMap for this to get the geo coordinates. Is there a an API to get this?

Any examples will help

Hi @Sreyams_Jain1,

Could you give me more information on your use case? Are you trying to display a map route on a GPS History block? Any extra information on what you would like to accomplish would be wonderful!

There are a few tools to get coordinates along a route, specifically OSRM. The OSRM Documentation has examples on how to request this data.

Thank you,

I am simulating similar to your Asset Tracker template example where the geocodes along the route is hard coded in a function. Instead of being hard coded in a function like that, I want to call an API which gives all those geo cordinates along that route. I want to know in this example how those 6943 or so coordinates obtained?

Hi, author of the Asset Tracker template here. First things first, yes, OpenStreetMaps has an API for obtaining route information including coordinates.

That said, that is not how I built the route you find in the Asset Tracker template. As you’ve pointed out, those coordinates are hard-coded into a Function Node (I used a Function Node because the size of the array prohibited it from being stored in an application global).

Here’s how I got those coordinates:

  1. Start at
  2. Enter your start point and end point in the top left corner. Make sure to also choose your transportation method (the default is “bike”)
  3. In the toolbar in the left, click the “Export” button. This will download a GPX file, which is a set of coordinates for the route in XML format.
  4. Then, convert the XML to JSON using an online tool.
  5. Finally, you’ll need a script (I wrote mine in Node) to do the following …
    • Pull the coordinates out of the object
    • Convert them to your desired format
    • (Optional but recommended: Reduce the precision of the points to a level you deem appropriate for your use case. The smaller the coordinate set, the easier and quicker it is to work with.

Let me know if this answers your questions and if you have any others.

Ok, so there is no single API within OSRM to get all the geo code points along the way in a json as such. Is that correct?

If so, with the method you used, is there a workflow that can be built to do all those steps and fetch the coordinates?

I can’t answer your question about an OSRM API, as all I know about it is what I learned from the link I posted in my previous answer. I will say that, the little I read did appear to at least return the information in some JSON format, but I doubt you can specify the format in which to return it and the precision of the coordinates.

As to a workflow, yes, one could be built to accomplish what i did in my Node script, at least using a Function Node if not using the other nodes in the palette.

Question: Are you looking to fetch the entire route in each run of the workflow? I would think you would want to cache that data in Workflow Storage if possible so as to avoid that heavy HTTP request. Either way you can then step through each point on the route.

One other thing I forgot to mention is you will want to take into consideration the pace at which you want this simulator to run. You can accomplish this by skipping a certain number of coordinates per run; that number will depend on how often your timer fires and how quickly you want the route to complete.

I can go with the same 2 minute interval to skip the gecodes along the way based on the total time it takes to complete the route. I will fetch all the geo codes upfront for the route.

If you have the API and the node script you used, please share. Appreciated

On the route that has the set of geocodes, is there a way to show the last geocode as well along with the current geocode location in a GPS history block?


There is not a way to show the last location as well along with the current location.

There is, though, the ability to change the popup details for the first or last point as the Icon Template field in the GPS History block using isLastPoint and isFirstPoint. We just released a How-To Guide on this exact thing!

Thank you,

if not, is there a way to show the route itself?


It is not possible to show the route itself.

This does seem like a great feature to add, though! I will create a Feature Request for this and update you should it be selected for development in the future.

Thank you,

@Sreyams_Jain1 in case you were still looking for a workflow that could take OSRM output and convert it into a JSON format, you should check out the Outdoor Asset Tracker data simulator template from our recently released Template Library. Within that template is a workflow that can take an exported route from OSRM and convert it into a JSON format that the simulator workflow can then use to spoof a device moving along your route.