rev. 409


Get latest version: gpx2map rev. 409

If you browse this file locally, please look at the homepage of gpx2map:


gpx2map reads a gps track in GPX format (as produced by e.g. gpsbabel) and writes out an Google Map or or OpenStreetMaps mash-up containing the route and a height profile. gpx2map can also show GPS-tagged photos along the map.

It comes very handy when you e.g. own an Garmin eTrex and want to know where you wandered around last time. Then you just use gpsbabel to fetch your tracks in GPX format and let gpx2map write out an map overlay for you.


HTML Include is put under the GNU General Public License.

    Copyright (C) 2007-2009 Robert Lange

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA


First of all Perl itself is needed, but also some packages from CPAN.
The CPAN-Modules can be found at

For Geo::Distance no pre-packaged version was available at the time of gpx2map development. Thus, there is an special work-around available: When Geo::Distance is not found globally, then as a second try it is searched in the directory cpan/ below the executable. When you have Geo::Distance installed at your system then you can safely delete the directory cpan/ in the distribution.

Chart::Gnuplot is required for drawing the height graph. When you don't want to use this feature this package is not needed.

Image::ExifTool and convert are required for adding geocoded images to the map. When you don't want to use this feature this package is not needed.

gpx2map is likely to work also with other versions than the one mentioned here. When you encounter problems just drop me a note.


Just copy (or link) the file gpx2map into your path or any place you like.
Put the mash-up template files, gpx2map.osm.template and where you put gpx2map itself (not to the link, in case you linked it).

When you don't have the CPAN module Geo::Distance installed then you also need to place the sub-directory cpan/ below the location you put gpx2map into. See also section Requirements.


The input file formal is GPX. You can get this e.g. by gpsbabel (gpx2map includes a shortcut for calling gpsbabel).
gpx2map then reads the GPX file and writes out a html page containing either an Google or OpenStreetMaps mash-up.

An GPX file can contain several tracks. You can select to write out only one specific track, merge all track points together or create one html file for each track.

When requested, GPS-tagged (so called geocoded) pictures are shown along with the track. For all supplied pictures an icon version (48x48 size, add ".ico" before the file suffix) and an shrinked version (640x640 size, add ".med" before the file suffix) are created. The icons are then placed directly on the map at the correct location. When you click these icons, the shrinked pictures along with position and time when the shot was taken are shown in an popup.
The described behaviour and defaults can be configured inside the script, see section Configuration. Currently the output for OpenStreetMaps is somewhat ugly and jumpy. When you can help me out with the OpenLayers API, you're welcome.

In case you don't have a camera with native GPS, you can use tools like gpscorrelate to add GPS-tags to your pictures. The tool takes your GPS track, compares the track time to the time stamps of the photos and adds the correlated position into the EXIF header.

Program Options

gpx2map [--help|-h] [--version|-V] [--route|-r route] [--merge]
[--title|-t title] [--osm|-o] [--yahoo|-y] [--[no]height]
[--outfile|-w file] inputfile [--pictures|-p img1 img2 ...]

--help, -h Help screen
--version, -V Version
--osm, -o Create OpenStreetMaps Mash-Up
--yahoo, -y Create Yahoo Mash-Up (broken)
Default is Google Mash-Up
--title, -t <title> Title of web page, when not specified use route name (or leave empty)
--route, -r <route> Route to read
--merge Use all points from all routes in gpx file
--outfile, -w <file> For --route or --merge progessing the ouput path and base filename can be given
--height|--noheight Enable (Default) or Disable height profile
--pictures|-p img1 img2 ... Place a shrinked version of these images on the map
Pictures must include GPS coordinates
inputfile GPX file to read
Can be compressed with gzip, bzip2, lzma

Output format is Google maps, unless --osm or --yahoo is given.
When neither --route nor --merge are specified, create individual web pages for each route.

Output is written to <inputfile_without_suffix>[.<route>].html


For your convenience gpsbabel can be invoked over gpx2map. Just use the following command line:

gpx2map --babel outfile


You can change certain settings of gpx2map operation in the header of the executable. Just search for "global settings".

In case you want to try out (or fix) the currently broken Yahoo interface you certainly want to change the Yahoo Maps API key. It's required when you want to upload the html pages to a server. Otherwise the API refuses to work.
Google recently (End of 2009) dropped the API key requirement in their Version 3 API.

Most common settings - the others are documented in the script itself:

Distance between Polyline points, in kilometer
Distance between mapping points in kilometer. Must be a multiple of map_line_dist
Height difference between height diagram points in meter. The more accurate your GPS records height information, the smaller value you can use here (and vice versa)
Call to gpsbabel, without output file name. The shell tokens are split up into fields.
You most certainly need to change here to use gpsbabel with gpx2map.


GPX File Google Output OSM Output
ischgl.xml ischgl-google.html ischgl-osm.html
juh.xml juh-google.html juh-osm.html
monte_viso.gpx monte_viso-google.html monte_viso-osm.html
italy_hiking.xml Monte Baldo
Brenta Dolomites

Known Issues

For picture placement to work you have to run gpx2map from the directory of the GPX file, and you cannot use absolute paths to pictures.

The browser compatibility could be improved.
gpx2map generated pages are tested sucessfully with Firefox 2 and 3, with most other (older) browsers you can expect drawbacks.

OpenStreetMaps Output for Picture placement is somewhat ugly and jumpy. I am still struggeling with the API and the lack of usable examples.

On third, the Yahoo Maps mash-up is broken and most probably won't be fixed, because I myself don't use it at all. You're welcome to provide me an updated template file to use with gpx2map.

To run gpx2map on windows probably have to make the following adaptions:
In the sub height_profile_image add the line: $filename =~ s{\\}{/}g;
In, sub _execute, replace the line my $gnuplot = 'gnuplot'; with
my $gnuplot = 'C:/gnuplot/bin/pgnuplot.exe';

When you want to contribute to gpx2map, just contact me.

Author and Credits

The author is Robert Lange <>
If you have any questions, just write me.

The home page of gpx2map is
Please look there for new versions.

created by rola Valid HTML 4.0! last modification: 2012-03-17
$LastChangedRevision: 418 $
$LastChangedDate: 2012-03-17 20:27:29 +0100 (Sat, 17 Mar 2012) $