Created
July 28, 2017 21:43
-
-
Save tschaub/7c551df6641efc6fa4c21b0acff04141 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 1. Go to http://labs.strava.com/gpx-to-route/ | |
* 2. Enter a Strava activity URL | |
* 3. Run this snippet | |
*/ | |
map.eachLayer(layer => { | |
if (layer.getLatLngs) { | |
const coordinates = layer.getLatLngs().map(latLng => { | |
return [latLng.lng, latLng.lat]; | |
}); | |
console.log( | |
`<?xml version="1.0" encoding="UTF-8"?> | |
<kml xmlns="http://www.opengis.net/kml/2.2"> | |
<Folder> | |
<name>Strava Export</name> | |
<description>Exported on ${new Date().toLocaleString()}</description> | |
<Placemark> | |
<name>Activity</name> | |
<description>Strava activity</description> | |
<LineString> | |
<coordinates> | |
${coordinates.map(coordinate => coordinate.join(',')).join(' ')} | |
</coordinates> | |
</LineString> | |
</Placemark> | |
</Folder> | |
</kml>`); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment