I try to create kml file from features.

My code

var feature=myVecLayer.getFeatureByFid('filedata.1');
                    var format;
                        function GetKMLFromFeatures(feature) {
                             format = new OpenLayers.Format.KML({
                                'internalProjection': new OpenLayers.Projection("EPSG:4326"),
                                'externalProjection': new OpenLayers.Projection("EPSG:4326")

                        return format.write(feature);

After i use this library to save file https://github.com/dcneiner/Downloadify

                            filename: function(){
                                return  'kml_test.kml';
                            data: function(){
                                return GetKMLFromFeatures(features);
                            onComplete: function(){
                                alert('Your File Has Been Saved!');
                            onCancel: function(){
                                alert('You have cancelled the saving of this file.');
                            onError: function(){
                                alert('You must put something in the File Contents or there will be nothing to save!');
                            transparent: false,
                            swf: 'media/downloadify.swf',
                            downloadImage: 'images/download.png',
                            width: 100,
                            height: 30,
                            transparent: true,
                            append: false

But nothing heppens. If firebug i get error

TypeError: f.el is null 


But more strange that i not get arert alert("okey");

Whats wrong? Or if someone know better way to get kml file please give me advice.

1 Answer 1


Keep in mind that by using Downloadify, your download will not work on mobile devices and pads. This is because Downloadify relies on flash and flash is dead. iPhones and iPads never supported it and now google has removed it from their play market.

I would write a handler in your back-end language of choice. Very easy, straight forward, and works everywhere.



Looks like there's a new way to do this client side. Please note the browser support.

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.