GPX files on Drupal

lenkkivihko - October 19, 2007 - 18:36

I am trying to build a site displaying GPS tracks.

Track module is quite good, but it works only on 4.7 and is not anymore supported.

What would be the best way to achieve similar functionality on 5.3?
Functionality = upload gpx-file and display it on a Gmap as a node.

The Track module does this

Christefano - October 19, 2007 - 19:31

The Track module does this but, yes, sadly it hasn't been updated to D5. I remember seeing a patch some time ago that adds GPX support in GMap that supports GPX files (check the issue queue).

Do you mean this?

lenkkivihko - October 19, 2007 - 20:02

http://drupal.org/node/135725

This patch is for 4.7. Perhaps I could try that one as well.

Gpx file support for 5.3 would be the ultimate goal.

Harjoituspäiväkirja - www.lenkkivihko.fi

Yes, that's the one

Christefano - October 19, 2007 - 22:44

Yes, that's the one. I haven't tried the patch, but I suggest posting a followup to the thread. The patch may not apply to gmap-5.x anymore but if you're a developer you may be able to learn something from the code.

The patch

lenkkivihko - October 20, 2007 - 08:42

It seems that the patch is quite simple as format.

Early part of the patch is about inclusion into the main module

diff --git a/gmap.module b/gmap.module
index b31869d..b57199f 100644
--- a/gmap.module
+++ b/gmap.module
@@ -1178,6 +1178,12 @@ function gmap_map_cleanup(&$map) {
     list($map['latitude'],$map['longitude']) = explode(',',$map['latlon']);
   }
   unset($map['latlon']);
+  // convert gpx data to markers and polygons
+  if (isset($map['gpx']) && function_exists('gmap_gpx_parse_file')) {
+    $gpxdata = gmap_gpx_parse_file($map['gpx']);
+    gmap_gpx_data2map($map, $gpxdata);
+    unset($map['gpx']);
+  }
}

function theme_gmap_coord($element) {
@@ -1369,3 +1375,6 @@ function gmap_decimal($num) {
   // Otherwise, cast to float, possibly losing precision.
   return (float) $num;
}
+
+// we now can parse gpx files

From this point onwards it's about GPX to macro conversion

+require_once(drupal_get_path('module','gmap') .'/gmap_gpx.inc');
diff --git a/gmap_gpx.inc b/gmap_gpx.inc
new file mode 100755
index 0000000..f19509e
--- /dev/null

I have done those edits to 5.x version. I could post the files to here as well.

Very practical challenge: How do I pass the GPX-file to the module? / how does one add nodes with with GPX file?

Harjoituspäiväkirja - www.lenkkivihko.fi

Subscribing

Quint - October 20, 2007 - 00:41

I was looking for the same thing. Still looking.

GPX tracks in Google Map

tom_ellenrieder - December 27, 2007 - 20:27

I'm looking for a way to add a path to a gpx file to the GMAP macro and for that GPX file then to be plotted as a track on the resulting map.

i don't understand the previous path unfortunately and don't know much and PHP.

I'm running drupal 5.

 
 

Drupal is a registered trademark of Dries Buytaert.