mapbox / leaflet-omnivore

universal format parser for Leaflet & Mapbox.js
https://www.mapbox.com/mapbox.js/example/v1.0.0/omnivore-gpx/
Other
647 stars 126 forks source link

Parse a.gpx as string #7

Closed esisa closed 10 years ago

esisa commented 10 years ago

If I try to read a.gpx as a string I get the following error:

TypeError: x.getElementsByTagName is not a function Line 542

Reading it as a file however, works just fine.

esisa commented 10 years ago

Here is an example of the string I use. This renders fine elsewhere.

data = '<?xml version="1.0" encoding="UTF-8"?><gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" version="1.0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd" creator="gpx.py -- https://github.com/tkrajina/gpxpy"><rte><rtept lat="44.907783722" lon="6.05487864642"><ele>1298.0</ele></rtept><rtept lat="44.9077732488" lon="6.05518996909"><ele>1301.0</ele></rtept></rte></gpx>';
tmcw commented 10 years ago

A documentation bug - right now the GPX parser expects an XML DOM rather than a string. I'll move the dom parsing parts behind the parse step so the docs & behavior match.

esisa commented 10 years ago

Aha... thanks!

tmcw commented 10 years ago

Fixed & deployed in 0.0.1.