import { useState } from 'react' import { Link } from 'react-router-dom' import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query' import api from '../utils/api' import { formatDistance, formatDuration, formatDate, formatPace, sportIcon } from '../utils/format' // Decode Google encoded polyline to [[lat,lng], ...] function decodePolyline(encoded) { if (!encoded) return [] const points = [] let idx = 0, lat = 0, lng = 0 while (idx < encoded.length) { let shift = 0, result = 0, byte do { byte = encoded.charCodeAt(idx++) - 63; result |= (byte & 0x1f) << shift; shift += 5 } while (byte >= 0x20) lat += result & 1 ? ~(result >> 1) : result >> 1 shift = 0; result = 0 do { byte = encoded.charCodeAt(idx++) - 63; result |= (byte & 0x1f) << shift; shift += 5 } while (byte >= 0x20) lng += result & 1 ? ~(result >> 1) : result >> 1 points.push([lat / 1e5, lng / 1e5]) } return points } function RouteMap({ polyline, className = '' }) { const pts = decodePolyline(polyline) if (pts.length < 2) return (
Routes are auto-detected when you run the same path twice. You can also create them manually.
Select an activity to use as the reference GPS track. Future activities on the same route will be linked automatically.
🗺️
No named routes yet
Routes are created automatically when you repeat a run, or create one manually above.
Merge another route into this one
All activities from the selected route will be moved here, then the other route will be deleted.
No other {selected.sport_type} routes to merge with.
)}Course record 🏆