mahdi n75 mahdi n75 - 8 months ago 76
HTML Question

How can i convert .txt to .gpx with an API in web or get GPX export?

i'm working on a web mapping project with openlayers (a JavaScript API for web GIS) and i need to make a option for users to get .gpx Export from coordinates that they have been before.

I am making an option to export TXT with a JavaScript API.

Is there any API to convert my TXT to GPX?

Is there a different method for exporting GPX files?


Sure that's possible with OpenLayers 3. You dont need to create an TXT first and then convert it to the GPX. In OpenLayers 3 there is a function called ol.format.GPX() which will convert your features to a gpx format. With writeFeatures() you can add you features to the ol gpx object. Here is a working JS FIDDLE.