show a map for a gpx file

969 Views Asked by At

I want to allow users to upload gpx files of a tracked route to my rails 3.2 app and to show them on a map, i.e. by using Google Maps.

How can I do that? Is there an easier way than parsing the gpx file by myself, store all waypoints in my database and provide them via json for the Google Maps API?

Thanks in advance!

1

There are 1 best solutions below

0
On

Sorry, not much of a Ruby expert. However, the Geographic Data Abstraction Library (GDAL) should handle this very well. GDAL has Ruby bindings: http://trac.osgeo.org/gdal/wiki/GdalOgrInRuby

I would suggest using it to convert GPX to KML and then using the KMLLayer object to display the KML. You would use ogr2ogr: http://gdal.org/ogr2ogr.html

Here's the KMLLayer: http://code.google.com/apis/maps/documentation/javascript/layers.html#KMLLayers