• Stars
    star
    142
  • Rank 258,495 (Top 6 %)
  • Language
    JavaScript
  • Created over 13 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Javascript GPX file viewer using Google Maps, updated for API v3

gpxviewer

This original version of this project is hosted on Google Code at http://code.google.com/p/gpxviewer/.

This fork adds support for version 3 of the Google Maps API, and the coding style of the library has been changed a bit for clarity. From the Google Code page:

The GPX viewer is a 100% client-side JavaScript GPX file viewer that uses Google Maps to map waypoints and tracklogs.

GPX files are a standard GPS data format that is supported by many software applications. It is an XML based data format which lends itself nicely to being parsed in JavaScript.

Since it is written entirely in JavaScript, this script can be added to any web page with minimal effort and little or no server code. Just copy a GPX file to your web site, make a web page with an embedded Google Map, include the script, and initialize it.

This script is meant to be customized to some extent. The default formatting for Waypoints is to show the available GPS data, but since it is Javascript, you can easily customize it to suite your needs.

Usage

Load the Google Maps JavaScript API v3, preferably at the end of the <body> of your document. (See Google's documentation if you need help.)

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

Make sure your page has a <div> to place the map, like this:

<div id="map" style="width: 100%; height: 100%;"></div>

Next you need to pass your GPX data to the GPXParser object - a quick way to do this is to perform an AJAX request using jQuery to retreive a GPX file hosted on the same web server as the map page.

(Note that you can't load a file from another server due to the same origin policy.)

You can grab jQuery from Google as well:

<script type="text/javascript"
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js">
</script>

Once these pieces are in place, loading JavaScript like this example should do the trick:

function loadGPXFileIntoGoogleMap(map, filename) {
    $.ajax({url: filename,
        dataType: "xml",
        success: function(data) {
          var parser = new GPXParser(data, map);
          parser.setTrackColour("#ff0000");     // Set the track line colour
          parser.setTrackWidth(5);          // Set the track line width
          parser.setMinTrackPointDelta(0.001);      // Set the minimum distance between track points
          parser.centerAndZoom(data);
          parser.addTrackpointsToMap();         // Add the trackpoints
          parser.addRoutepointsToMap();         // Add the routepoints
          parser.addWaypointsToMap();           // Add the waypoints
        }
    });
}

$(document).ready(function() {
    var mapOptions = {
      zoom: 8,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map"),
        mapOptions);
    loadGPXFileIntoGoogleMap(map, "pocotrail.xml");
});

Acknowledgements

Thanks to Kaz Okuda for the original version of this library.

The blog post describing the original version.

License

This project is licensed under the GNU GPL v3 license.

More Repositories

1

pygatt

Python wrapper for gatttool (a deprecated tool from BlueZ) and the BGAPI for accessing Bluetooth LE Devices
Python
521
star
2

astral

A P2P content distribution network for live video
Python
25
star
3

arduino.mk

DEPRECATED FORK: Arduino Makefile with chipKIT support
Shell
11
star
4

redmine_create_wiki_page

Redmine plugin that adds a "New" button to each wiki page
HTML
8
star
5

head-pose-estimator

Slightly modified source from a paper by Gabriele Fanelli et. all
C++
8
star
6

vim-phabrowse

vim-fugitive extension for Phabricator
Vim Script
5
star
7

astral-web

Web Interface for Astral
JavaScript
4
star
8

threephase

Real-time electric power system strategy game (on Rails)
JavaScript
4
star
9

pflac

modifications to the official FLAC encoder (circa 2008) for parallel encoding
C++
3
star
10

trinity

RESTful neo4j wrapper in Python
Python
3
star
11

jtrie

A Java trie (prefix tree)
Java
3
star
12

asterisk-cookbook

DEPRECATED: Asterisk cookbook for Chef, with Google Voice support
Ruby
3
star
13

netflix-ratings-extractor

Fork of source from userscripts.org
JavaScript
3
star
14

orbiterjs

ProcessingJS Rocket Launch to Orbit Simulator
JavaScript
3
star
15

asterisk-google-voice-config

Minimal configuration for Asterisk 11 to use Google Voice for calls
3
star
16

spade

Experimental HTTP Server for Dynamic Content in C
C
2
star
17

ecomcat_to_openxc

Convet ECOMCat CAN message trace files to the OpenXC raw CAN format
Python
2
star
18

august23

August 23, 1966 - a University of MIchigan GROCS project from 2009
Java
2
star
19

wiremap-shapes

A few gemoetric shapes for a Wiremap, powered by Processing
Java
1
star
20

catman

Processing
1
star
21

hab-visualizer

JavaScript
1
star
22

pulse-oximeter

Processing
1
star
23

jsvim-tiddly

jsvim Plugin for TiddlyWiki
JavaScript
1
star
24

ati_remote

ATI Remote Wonder Linux Kernel Module (ati_remote)
C
1
star
25

hoppy

Hoptoad API in Python
Python
1
star
26

asana-burndown

Use the Asana API to calculate task counts and project burndown
Python
1
star
27

neb

Python library to access the Trinity API
Python
1
star
28

bueda-ruby

Lightweight Ruby wrapper for the Bueda API
Ruby
1
star
29

riddly

ActiveRecord models for an existing ccTiddly database
Ruby
1
star
30

peplin.github.com

SCSS
1
star
31

rdiosync

Rdio Filesystem Collection Sync
Python
1
star
32

git-presentation

showoff presentation on Git
1
star
33

scrapescrobbler

Submit songs to last.fm from old-fashioned radio stations
Ruby
1
star