I want to export a KML file from points plotted in Javascript using the Google Maps API. Is there a way to do this? The user logs in and checks Google Maps, then plot points on the map and finally export those points in a KML format.

NOTE:I am not using PHP.


1 Answer 1


Well, to my knowledge it would be rather hard to create a new file, on the fly, for a user to download without some sort of server-side work (ex: via PHP, ASP, ... or something of the sort). Also, the comment above may or may not meet exactly what you're looking for.

But, that said, if you're wanting to create your own solution more from scratch, then at least it wouldn't be that hard to have the javascript read through all the user added points and use that data and plug it into a template you type up, and have the result be your page opening a new web page or a new box on the current page that has all of the contents of the KML file you would need to generate. Then, the users could just copy and paste that to a local blank file on their machine and make sure to name it .kml at the end. That would really depend on the kind of user you're targeting, but, like I said, I don't know that there's a good way to make a downloadable file on the fly without some server side code executing rather than all client side (ex: javascript).

If you'd need help with creating the KML file, you can find all the KML documentation at https://developers.google.com/kml/documentation/kmlreference. Then just take what you need for a basic KML point file and have the javascript plug in the coordinates and such of each graphic added to the map into the appropriate place within the KML code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.