From b051fe1e40cd8e737567eaafef2a0464a472b5fb Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Thu, 8 Dec 2016 10:46:36 +0100 Subject: [PATCH] add gpx route parsing --- CHANGELOG.md | 1 + js/gpxedit.js | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc5ddb6..72c1fd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). [#6](https://gitlab.com/eneiluj/gpxedit-oc/issues/6) @eneiluj - symbol selects include icons [#6](https://gitlab.com/eneiluj/gpxedit-oc/issues/6) @eneiluj +- gpx route parsing ### Changed - detach marker and tooltip styling option diff --git a/js/gpxedit.js b/js/gpxedit.js index f96763d..d6a0083 100644 --- a/js/gpxedit.js +++ b/js/gpxedit.js @@ -581,9 +581,9 @@ function parseGpx(xml){ }); dom.find('trk').each(function(){ var latlngs = []; - var name = $(this).find('name').text(); - var cmt = $(this).find('cmt').text(); - var desc = $(this).find('desc').text(); + var name = $(this).find('>name').text(); + var cmt = $(this).find('>cmt').text(); + var desc = $(this).find('>desc').text(); $(this).find('trkseg').each(function(){ $(this).find('trkpt').each(function(){ var lat = $(this).attr('lat'); @@ -599,6 +599,24 @@ function parseGpx(xml){ }); drawLine(latlngs, name, desc, cmt); }); + dom.find('rte').each(function(){ + var latlngs = []; + var name = $(this).find('>name').text(); + var cmt = $(this).find('>cmt').text(); + var desc = $(this).find('>desc').text(); + $(this).find('rtept').each(function(){ + var lat = $(this).attr('lat'); + var lon = $(this).attr('lon'); + var ele = $(this).find('ele').text(); + if (ele !== ''){ + latlngs.push([lat,lon,ele]); + } + else{ + latlngs.push([lat,lon]); + } + }); + drawLine(latlngs, name, desc, cmt); + }); } // remove layers from map and delete all layers data