Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strava API - How to get route image

Does anyone know how to get finish route map image after users post their activity on Strava. I have read Strava API document, but I haven't found it yet

I use https://strava.github.io/api/v3/activities/:id to get an activity, there is "map" field, but I still not find out this field description.

enter image description here

Thanks everyone.

like image 996
Phu Sanh Avatar asked Dec 29 '17 05:12

Phu Sanh


People also ask

What map API does Strava use?

Strava utilizes OpenStreetMap, an open-source project that distributes geographical data for the entire world, alongside our own heat/popularity and other unique data, to create both the visual experience for maps as well as to help inform routing decisions and points of interest shown on the map.

How do you make a route colorful on Strava?

Changing your Strava route to be rainbow coloured is simple. All you need to do is add a rainbow emoji to the title of your route and voila!

Why can't I see my route on Strava?

Your device may have simply lost a connection to GPS satellites and did not record any data. Your Strava activity may be missing a map, show a straight line connecting your start and endpoints, or was automatically tagged as an indoor activity. Your device may have recorded GPS points that deviate from your true path.

Can you export Strava route to Google Maps?

It's pretty simple, first paste the Strava ride page link into http://cosmocatalano.com/strava-gpx-export/. It will generate a gpx file link out of the Strava ride page. Then paste that "download gpx file" link into the Google Maps search field, it will then create the map for it in Google Maps.


2 Answers

Strava takes the set of lat/longs recorded, and encodes them using the GOOGLE POLYLINE ENCODING algorithm. This is in order to reduce the data transmitted through the APP and the WEB SERVICE.

If you need to draw the route, you need to

  1. Take the polyline string.
  2. Decode it to get an array of lat/lon.
  3. Loop through the array and draw the polyline on the maps.

I used the @mapbox/polyline npm module to decode the polyline in javascript.

Another, and a better way to do that is that you use the google maps static api. Where you will input a polyline, and get an image with a route drawn. The static api will look like

https://maps.googleapis.com/maps/api/staticmap?size=600x300&maptype=roadmap&path=enc:GIVE_YOUR_POLYLINE_DATA&key=GIVE_YOUR_API_KEY

like image 197
Abhishek Sharma Avatar answered Sep 21 '22 07:09

Abhishek Sharma


The summary_polyline can be decoded into a set of coordinates. The algorithm used for a polyline is described here and lots of libraries can handle it.

You can also use the Google Maps static API for example without decoding.

This Ruby code from a slack bot for Strava does it all.

like image 33
dB. Avatar answered Sep 23 '22 07:09

dB.