mahdi n75 mahdi n75 - 10 months ago 91
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?

Answer Source

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.