Displaying GPX data with Google Earth plug-in

487 views
Skip to first unread message

walkhighlands

unread,
Feb 17, 2010, 6:36:02 AM2/17/10
to KML Developer Support - Google Earth Plug-in
Does anyone have an example of doing this?

I just want a page using the Google Earth plug-in to show data from a
gpx file (Track or route) to display it as a polyline in the plugin.

StarTraX

unread,
Feb 17, 2010, 4:17:56 PM2/17/10
to KML Developer Support - Google Earth Plug-in
You have to convert it to KML first. - GPSBabel is a great tool to do
the conversion, or, if it's a true GPS track, you can replay it in
StarTraX (gpsanimator.com - free!)

walkhighlands

unread,
Feb 18, 2010, 3:07:23 AM2/18/10
to KML Developer Support - Google Earth Plug-in
That's not an option- these gps files are the server is processing for
lots of other apps. There must be someone who has written some php
code to parse a GPX file into a GE polyline?

Markw65

unread,
Feb 18, 2010, 10:48:47 AM2/18/10
to KML Developer Support - Google Earth Plug-in
Yes, its quite straightforward. Just read the .gpx file as a .xml, and
then create a string with the coords of each point. Construct a
KmlLinestring from that.

I have some code to do this - but it does a lot more as well; it also
reads .tcx and .fitlog files, and converts everything into an internal
format suitable for further analysis, and for plotting graphs etc -
but it would take very little code to just produce a ge polyline from
a .gpx file...

If you need more details, I can try and extract the basics from my
code and post it. Let me know.

Mark

Forrest

unread,
Feb 19, 2010, 8:27:39 PM2/19/10
to KML Developer Support - Google Earth Plug-in
Howdy,
have you looked at GpicSynch?

http://code.google.com/p/gpicsync/

It'll tag pics from your digital camera from your GPS's GPX file,
assuming of course you had your GPS on at the same time you had your
camera on, and that your camera and GPS are set to the same time.

The point: the free app gpicsync will spit out a KML file...and the
GPX track will show as a polyline in the KML, with the pictures as
clickable thumbnails like bread crumbs along the route/track...sooooo
I don't think you absolutely have to have a picture, and believe you
could probably just upload you GPX to the gpicsync app, and spit out a
KML.

Hope this helps, and let us know if gpicsync works for ya'll

Forrest

walkhighlands

unread,
Feb 20, 2010, 8:34:48 AM2/20/10
to KML Developer Support - Google Earth Plug-in
Markw65

That sounds the ticket. If you could post the basic code (I can
probably strip out stuff not needed) that would be hugely helpful.

Cheers
Paul

walkhighlands

unread,
Mar 13, 2010, 5:51:32 AM3/13/10
to KML Developer Support - Google Earth Plug-in
Has anyone got any code examples that we could use which display gpx
tracks in the Google Earth plug-in API? I'm looking for something that
does this on our webpages, not to convert some of my own files from
gpx to kml (GE itself can do that!)

jankoc

unread,
Mar 15, 2010, 7:55:32 AM3/15/10
to KML Developer Support - Google Earth Plug-in
Some code to parse (a simple type of) gpx-data in a div with ID
"gpxdata" via jQuery might be a starting point for you?

var lats=new Array();
var lngs=new Array();

$(parseXml($("#gpxdata").val())).find('trkpt').each(function(){
var lat = parseFloat($(this).attr('lat'));
var lng = parseFloat($(this).attr('lon'));
lats.push(latn);
lngs.push(lngn);
}

I use it to let the website visitor paste a gpx-file into a form, and
plot a line for the track. Drawing the line from the lats/lngs array
is straightforward.

Reply all
Reply to author
Forward
0 new messages