gmaps2gpx
Convert Google Maps direction URLs to GPX files with a single command.
Features
- Shortened URLs - Paste
maps.app.goo.gllinks directly - Dragged routes - Preserves via-points when you drag a route on Google Maps
- Motorcycle mode - Two-wheeler routing via Google Routes API (great for India/SE Asia)
- Alternative routes -
--shortestpicks the shortest route by distance - Batch convert - Pass multiple URLs at once
- All travel modes - driving, walking, bicycling, transit, motorcycle
Install
# From PyPI
pip install gmaps2gpx
# Or with pipx (recommended - isolated install)
pipx install gmaps2gpx
# From source
git clone https://github.com/prajwalp/gmaps2gpx.git
cd gmaps2gpx
pip install .
Setup
You need a Google Maps API key with Directions API enabled. For motorcycle mode, also enable the Routes API.
# Set it once (add to your .bashrc/.zshrc)
export GOOGLE_MAPS_API_KEY="your_key_here"
Or pass it each time with -k YOUR_KEY.
Getting an API key
- Go to Google Cloud Console
- Create a project (or select existing)
- Enable Directions API (and Routes API for motorcycle mode)
- Create an API key under Credentials
- (Optional) Restrict the key to Directions API + Routes API
Usage
# Basic - paste any Google Maps directions link
gmaps2gpx 'https://maps.app.goo.gl/Mz9Q47fcBMHLa2HB7'
# Save to specific file
gmaps2gpx 'https://maps.app.goo.gl/abc123' -o ride.gpx
# Motorcycle / two-wheeler mode (uses Google Routes API)
gmaps2gpx 'https://maps.app.goo.gl/abc123' -m motorcycle -o ride.gpx
# Pick the shortest route from alternatives
gmaps2gpx 'https://maps.app.goo.gl/abc123' --shortest
# Full Google Maps URL works too
gmaps2gpx 'https://www.google.com/maps/dir/Mumbai/Goa' -o mumbai_goa.gpx
# Walking directions
gmaps2gpx 'https://maps.app.goo.gl/abc123' -m walking
# Batch convert multiple routes
gmaps2gpx URL1 URL2 URL3
# Pass API key directly
gmaps2gpx 'https://maps.app.goo.gl/abc123' -k YOUR_API_KEY
Options
positional arguments:
urls one or more Google Maps direction URLs
options:
-k, --api-key KEY Google Maps API key (or set GOOGLE_MAPS_API_KEY env var)
-o, --output FILE output GPX filename (auto-generated if omitted)
-m, --mode MODE travel mode: driving, walking, bicycling, transit, motorcycle
-s, --shortest fetch alternatives and pick the shortest by distance
-h, --help show help
How it works
- Resolves shortened Google Maps URLs
- Parses origin, destination, waypoints, and dragged via-points from the URL
- Calls Google Directions API (or Routes API for motorcycle mode)
- Decodes polylines into GPS coordinates
- Generates a GPX 1.1 file with track points and waypoint markers
Publishing to PyPI
One-time setup:
# Install build tools
pip install build twine
# Create a PyPI account at https://pypi.org/account/register/
# Generate an API token at https://pypi.org/manage/account/
To publish:
# Build the package
python -m build
# Upload to PyPI
twine upload dist/*
# You'll be prompted for credentials:
# Username: __token__
# Password: pypi-YOUR_API_TOKEN
After publishing, anyone can install with:
pip install gmaps2gpx
License
MIT
Release files for gmaps2gpx 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gmaps2gpx-1.0.0.tar.gz | 8.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gmaps2gpx-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.3 kB
Release files / gmaps2gpx-1.0.0.tar.gz
| Download URL | gmaps2gpx-1.0.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb36b40ef51ea7bd80610a36c011c8cc1c2b3709e42dd1b0e0c4bb31768ebc44
|
|
BLAKE2b-256 checksum How to use checksums |
c13e7afff4d6fbb32b63a16b1516463def9a72097281698604aa93c03cdd963c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / gmaps2gpx-1.0.0-py3-none-any.whl
| Download URL | gmaps2gpx-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32bbead16617150a1b16abe1dfae43f8f30576d3a93d85a6af7f10c592462a94
|
|
BLAKE2b-256 checksum How to use checksums |
740bdeab8f4578d005f9eea7e343f63965633f0a81e232dc25cef0cb8de6f8fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|