{"id":17011,"date":"2017-05-02T12:15:24","date_gmt":"2017-05-02T09:15:24","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=17011"},"modified":"2017-05-01T14:43:51","modified_gmt":"2017-05-01T11:43:51","slug":"leaflet-mapping-strava-runspolylines-open-street-map","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/","title":{"rendered":"Leaflet: Mapping Strava runs\/polylines on Open Street Map"},"content":{"rendered":"<p>I\u2019m a big <a href=\"https:\/\/www.strava.com\/athletes\/6958432\">Strava<\/a> user and spent a bit of time last weekend playing around with <a href=\"https:\/\/strava.github.io\/api\/v3\/athlete\/\">their API<\/a> to work out how to map all my runs.<\/p>\n<h3>Strava API and polylines<\/h3>\n<p>This is a two step process:<\/p>\n<ol>\n<li>Call the <cite>\/athlete\/activities\/<\/cite> endpoint to get a list of all my activities<\/li>\n<li>For each of those activities call <cite>\/activities\/[activityId]<\/cite> endpoint to get more detailed information for each activity<\/li>\n<\/ol>\n<p>That second API returns a \u2018polyline\u2019 property which the <a href=\"https:\/\/strava.github.io\/api\/#polylines\">documentation<\/a> describes as follows:<\/p>\n<blockquote><p>Activity and segment API requests may include summary polylines of their respective routes. The values are string encodings of the latitude and longitude points using the <a href=\"https:\/\/developers.google.com\/maps\/documentation\/utilities\/polylinealgorithm\">Google encoded polyline algorithm format<\/a>.<\/p><\/blockquote>\n<p>If we navigate to that page we get the following explanation:<\/p>\n<blockquote><p>Polyline encoding is a lossy compression algorithm that allows you to store a series of coordinates as a single string.<\/p><\/blockquote>\n<p>I tried out a couple of my polylines using the <a href=\"https:\/\/developers.google.com\/maps\/documentation\/utilities\/polylineutility\">interactive polyline encoder utility<\/a> which worked well once I realised that I needed to escape backslashes (\u201c\\\u201d) in the polyline before pasting it into the tool.<\/p>\n<p>Now that I\u2019d figured out how to map one run it was time to automate the process.<\/p>\n<h3>Leaflet and OpenStreetMap<\/h3>\n<p>I\u2019ve previously had a good experience using <a href=\"http:\/\/leafletjs.com\/\">Leaflet<\/a> so I was keen to use that and luckily came across <a href=\"http:\/\/stackoverflow.com\/a\/40728445\/1093511\">a Stack Overflow answer<\/a> showing how to do what I wanted.<\/p>\n<p>I created a HTML file and manually pasted in a couple of my runs (not forgetting to escape those backslashes!) to check that they worked:<\/p>\n<p><cite>blog.html<\/cite><\/p>\n<pre class=\"brush:xml; wrap-lines:false\">&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;Mapping my runs&lt;\/title&gt;\r\n  &lt;\/head&gt;\r\n\u00a0\r\n  &lt;body&gt;\r\n    &lt;script src=\"http:\/\/cdn.leafletjs.com\/leaflet-0.7\/leaflet.js\"&gt;&lt;\/script&gt;\r\n    &lt;script type=\"text\/javascript\" src=\"https:\/\/rawgit.com\/jieter\/Leaflet.encoded\/master\/Polyline.encoded.js\"&gt;&lt;\/script&gt;\r\n    &lt;link rel=\"stylesheet\" href=\"http:\/\/cdn.leafletjs.com\/leaflet-0.7\/leaflet.css\" \/&gt;\r\n    &lt;div id=\"map\" style=\"width: 100%; height: 100%\"&gt;&lt;\/div&gt;\r\n\u00a0\r\n    &lt;script&gt;\r\n    var map = L.map('map').setView([55.609818, 13.003286], 13);\r\n    L.tileLayer(\r\n        'http:\/\/{s}.tile.openstreetmap.org\/{z}\/{x}\/{y}.png', {\r\n            maxZoom: 18,\r\n        }).addTo(map);\r\n\u00a0\r\n    var encodedRoutes = [\r\n      \"{zkrIm`inANPD?BDXGPKLATHNRBRFtAR~AFjAHl@D|ALtATj@HHJBL?`@EZ?NQ\\\\Y^MZURGJKR]RMXYh@QdAWf@[~@aAFGb@?j@YJKBU@m@FKZ[NSPKTCRJD?`@Wf@Wb@g@HCp@Qh@]z@SRMRE^EHJZnDHbBGPHb@NfBTxBN|DVbCBdA^lBFl@Lz@HbBDl@Lr@Bb@ApCAp@Ez@g@bEMl@g@`B_AvAq@l@    QF]Rs@Nq@CmAVKCK?_@Nw@h@UJIHOZa@xA]~@UfASn@U`@_@~@[d@Sn@s@rAs@dAGN?NVhAB\\\\Ox@@b@S|A?Tl@jBZpAt@vBJhATfGJn@b@fARp@H^Hx@ARGNSTIFWHe@AGBOTAP@^\\\\zBMpACjEWlEIrCKl@i@nAk@}@}@yBOWSg@kAgBUk@Mu@[mC?QLIEUAuAS_E?uCKyCA{BH{DDgF`AaEr@uAb@oA~@{AE}AKw@    g@qAU[_@w@[gAYm@]qAEa@FOXg@JGJ@j@o@bAy@NW?Qe@oCCc@SaBEOIIEQGaAe@kC_@{De@cE?KD[H[P]NcAJ_@DGd@Gh@UHI@Ua@}Bg@yBa@uDSo@i@UIICQUkCi@sCKe@]aAa@oBG{@G[CMOIKMQe@IIM@KB]Tg@Nw@^QL]NMPMn@@\\\\Lb@P~@XT\",\r\n      \"u}krIq_inA_@y@My@Yu@OqAUsA]mAQc@CS@o@FSHSp@e@n@Wl@]ZCFEBK?OC_@Qw@?m@CSK[]]EMBeAA_@m@qEAg@UoCAaAMs@IkBMoACq@SwAGOYa@IYIyA_@kEMkC]{DEaAScC@yEHkGA_ALsCBiA@mCD{CCuAZcANOH@HDZl@Z`@RFh@\\\\TDT@ZVJBPMVGLM\\\\Mz@c@NCPMXERO|@a@^Ut@s@p@KJAJ    Bd@EHEXi@f@a@\\\\g@b@[HUD_B@uADg@DQLCLD~@l@`@J^TF?JANQ\\\\UbAyABEZIFG`@o@RAJEl@_@ZENDDIA[Ki@BURQZaARODKVs@LSdAiAz@G`BU^A^GT@PRp@zARXRn@`BlDHt@ZlAFh@^`BX|@HHHEf@i@FAHHp@bBd@v@DRAVMl@i@v@SROXm@tBILOTOLs@NON_@t@KX]h@Un@k@\\\\c@h@Ud@]ZGNKp@Sj@KJo@    b@W`@UPOX]XWd@UF]b@WPOAIBSf@QVi@j@_@V[b@Uj@YtAEFCCELARBn@`@lBjAzD^vB^hB?LENURkAv@[Ze@Xg@Py@p@QHONMA[HGAWE_@Em@Hg@AMCG@QHq@Cm@M[Jy@?UJIA{@Ae@KI@GFKNIX[QGAcAT[JK?OVMFK@IAIUKAYJI?QKUCGFIZCXDtAHl@@p@LjBCZS^ERAn@Fj@Br@Hn@HzAHh@RfD?j@TnCTlA    NjANb@\\\\z@TtARr@P`AFnAGfBG`@CFE?\"\r\n  ]\r\n\u00a0\r\n    for (let encoded of encodedRoutes) {\r\n      var coordinates = L.Polyline.fromEncoded(encoded).getLatLngs();\r\n\u00a0\r\n      L.polyline(\r\n          coordinates,\r\n          {\r\n              color: 'blue',\r\n              weight: 2,\r\n              opacity: .7,\r\n              lineJoin: 'round'\r\n          }\r\n      ).addTo(map);\r\n    }\r\n    &lt;\/script&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>We can spin up a Python web server over that HTML file to see how it renders:<\/p>\n<pre class=\"brush:py\">$ python -m http.server\r\nServing HTTP on 0.0.0.0 port 8000 (http:\/\/0.0.0.0:8000\/) ...<\/pre>\n<p>And below we can see both runs plotted on the map.<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/05\/2017-04-29_15-53-28.png\"><img decoding=\"async\" class=\"aligncenter wp-image-17015\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/05\/2017-04-29_15-53-28.png\" alt=\"\" width=\"860\" height=\"375\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/05\/2017-04-29_15-53-28.png 1196w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/05\/2017-04-29_15-53-28-300x131.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/05\/2017-04-29_15-53-28-768x335.png 768w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/05\/2017-04-29_15-53-28-1024x447.png 1024w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<h3>Automating Strava API to Open Street Map<\/h3>\n<p>The final step is to automate the whole thing so that I can see all of my runs.<\/p>\n<p>I wrote the following script to call the Strava API and save the polyline for every run to a CSV file:<\/p>\n<pre class=\"brush:py\">import requests\r\nimport os\r\nimport sys\r\nimport csv\r\n\u00a0\r\ntoken = os.environ[\"TOKEN\"]\r\nheaders = {'Authorization': \"Bearer {0}\".format(token)}\r\n\u00a0\r\nwith open(\"runs.csv\", \"w\") as runs_file:\r\n    writer = csv.writer(runs_file, delimiter=\",\")\r\n    writer.writerow([\"id\", \"polyline\"])\r\n\u00a0\r\n    page = 1\r\n    while True:\r\n        r = requests.get(\"https:\/\/www.strava.com\/api\/v3\/athlete\/activities?page={0}\".format(page), headers = headers)\r\n        response = r.json()\r\n\u00a0\r\n        if len(response) == 0:\r\n            break\r\n        else:\r\n            for activity in response:\r\n                r = requests.get(\"https:\/\/www.strava.com\/api\/v3\/activities\/{0}?include_all_efforts=true\".format(activity[\"id\"]), headers = headers)\r\n                polyline = r.json()[\"map\"][\"polyline\"]\r\n                writer.writerow([activity[\"id\"], polyline])\r\n            page += 1<\/pre>\n<p>I then wrote a simple script using <a href=\"http:\/\/flask.pocoo.org\/\">Flask<\/a> to parse the CSV files and send a JSON representation of my runs to a slightly modified version of the HTML page that I described above:<\/p>\n<pre class=\"brush:py\">from flask import Flask\r\nfrom flask import render_template\r\nimport csv\r\nimport json\r\n\u00a0\r\napp = Flask(__name__)\r\n\u00a0\r\n@app.route('\/')\r\ndef my_runs():\r\n    runs = []\r\n    with open(\"runs.csv\", \"r\") as runs_file:\r\n        reader = csv.DictReader(runs_file)\r\n\u00a0\r\n        for row in reader:\r\n            runs.append(row[\"polyline\"])\r\n\u00a0\r\n    return render_template(\"leaflet.html\", runs = json.dumps(runs))\r\n\u00a0\r\nif __name__ == \"__main__\":\r\n    app.run(port = 5001)<\/pre>\n<p>I changed the following line in the HTML file:<\/p>\n<pre class=\"brush:java\">var encodedRoutes = {{ runs|safe }};<\/pre>\n<p>Now we can launch our Flask web server:<\/p>\n<pre class=\"brush:py\">$ python app.py \r\n * Running on http:\/\/127.0.0.1:5001\/ (Press CTRL+C to quit)<\/pre>\n<p>And if we navigate to <cite>http:\/\/127.0.0.1:5001\/<\/cite> we can see all my runs that went near Westminster:<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/05\/2017-04-29_16-32-00.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-17016\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/05\/2017-04-29_16-32-00.png\" alt=\"\" width=\"672\" height=\"504\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/05\/2017-04-29_16-32-00.png 672w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/05\/2017-04-29_16-32-00-300x225.png 300w\" sizes=\"(max-width: 672px) 100vw, 672px\" \/><\/a><\/p>\n<p>The full code for all the files I\u2019ve described in this post are <a href=\"https:\/\/gist.github.com\/mneedham\/34b923beb7fd72f8fe6ee433c2b27d73\">available on github<\/a>. If you give it a try you\u2019ll need to provide your Strava Token in the \u2018TOKEN\u2019 environment variable before running <cite>extract_runs.py<\/cite>.<\/p>\n<p>Hope this was helpful and if you have any questions ask me in the comments.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/www.markhneedham.com\/blog\/2017\/04\/29\/leaflet-strava-polylines-osm\/\">Leaflet: Mapping Strava runs\/polylines on Open Street Map<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\">WCG partner<\/a> Mark Needham at the <a href=\"http:\/\/www.markhneedham.com\/blog\/\">Mark Needham Blog<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019m a big Strava user and spent a bit of time last weekend playing around with their API to work out how to map all my runs. Strava API and polylines This is a two step process: Call the \/athlete\/activities\/ endpoint to get a list of all my activities For each of those activities call &hellip;<\/p>\n","protected":false},"author":48,"featured_media":1651,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[466],"class_list":["post-17011","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-strava"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Leaflet: Mapping Strava runs\/polylines on Open Street Map - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"I\u2019m a big Strava user and spent a bit of time last weekend playing around with their API to work out how to map all my runs. Strava API and polylines This\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Leaflet: Mapping Strava runs\/polylines on Open Street Map - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"I\u2019m a big Strava user and spent a bit of time last weekend playing around with their API to work out how to map all my runs. Strava API and polylines This\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-05-02T09:15:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mark Needham\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mark Needham\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/\"},\"author\":{\"name\":\"Mark Needham\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/848a54e2ee724e46069ce36c2e52e98e\"},\"headline\":\"Leaflet: Mapping Strava runs\/polylines on Open Street Map\",\"datePublished\":\"2017-05-02T09:15:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/\"},\"wordCount\":485,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"keywords\":[\"Strava\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/\",\"name\":\"Leaflet: Mapping Strava runs\/polylines on Open Street Map - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"datePublished\":\"2017-05-02T09:15:24+00:00\",\"description\":\"I\u2019m a big Strava user and spent a bit of time last weekend playing around with their API to work out how to map all my runs. Strava API and polylines This\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Leaflet: Mapping Strava runs\/polylines on Open Street Map\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/848a54e2ee724e46069ce36c2e52e98e\",\"name\":\"Mark Needham\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5489baed26ce2d932bf951ecfb47afe80bec45d3648c23521d87c83b8f1c3ea9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5489baed26ce2d932bf951ecfb47afe80bec45d3648c23521d87c83b8f1c3ea9?s=96&d=mm&r=g\",\"caption\":\"Mark Needham\"},\"sameAs\":[\"http:\/\/www.markhneedham.com\/blog\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/mark-needham\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Leaflet: Mapping Strava runs\/polylines on Open Street Map - Web Code Geeks - 2026","description":"I\u2019m a big Strava user and spent a bit of time last weekend playing around with their API to work out how to map all my runs. Strava API and polylines This","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/","og_locale":"en_US","og_type":"article","og_title":"Leaflet: Mapping Strava runs\/polylines on Open Street Map - Web Code Geeks - 2026","og_description":"I\u2019m a big Strava user and spent a bit of time last weekend playing around with their API to work out how to map all my runs. Strava API and polylines This","og_url":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-05-02T09:15:24+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","type":"image\/jpeg"}],"author":"Mark Needham","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Mark Needham","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/"},"author":{"name":"Mark Needham","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/848a54e2ee724e46069ce36c2e52e98e"},"headline":"Leaflet: Mapping Strava runs\/polylines on Open Street Map","datePublished":"2017-05-02T09:15:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/"},"wordCount":485,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","keywords":["Strava"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/","url":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/","name":"Leaflet: Mapping Strava runs\/polylines on Open Street Map - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","datePublished":"2017-05-02T09:15:24+00:00","description":"I\u2019m a big Strava user and spent a bit of time last weekend playing around with their API to work out how to map all my runs. Strava API and polylines This","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/python-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/python\/leaflet-mapping-strava-runspolylines-open-street-map\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/www.webcodegeeks.com\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Leaflet: Mapping Strava runs\/polylines on Open Street Map"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/848a54e2ee724e46069ce36c2e52e98e","name":"Mark Needham","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5489baed26ce2d932bf951ecfb47afe80bec45d3648c23521d87c83b8f1c3ea9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5489baed26ce2d932bf951ecfb47afe80bec45d3648c23521d87c83b8f1c3ea9?s=96&d=mm&r=g","caption":"Mark Needham"},"sameAs":["http:\/\/www.markhneedham.com\/blog\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/mark-needham\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/17011","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/48"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=17011"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/17011\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/1651"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=17011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=17011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=17011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}