AW: [OpenLayers-Users] WFS getFeature, save result as gml

Arnd Wippermann arnd.wippermann at web.de
Tue Oct 4 15:24:48 EDT 2011


Hi,

The most common way is to do it by a server side script.

But it's also possible with client side javascript:

http://davidwalsh.name/downloadify

or if you use FF, it's possible with an url:

var content = escape(document.getElementById("taMessage").value);
var url = "data:application/txt," + content;
window.open(url);

FF asks for download the data.

Arnd




-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von stash
Gesendet: Dienstag, 4. Oktober 2011 13:44
An: users at openlayers.org
Betreff: [OpenLayers-Users] WFS getFeature, save result as gml

Hello,

I'm using a WFS to show some content on my map. Furthermore I there is a wfs
getfeature to show the attributes of the wfs entries, when the user is
clicking on them. This is working fine so far.

Now I want to add something like an export-function. The result of a wfs
getfeature is a gml, but I haven't seen any possibility to export this gml
in openlayers. 


Here is some of my code:

1) wfs

var wfs_layer = new OpenLayers.Layer.Vector("table_1",
{
    strategies: [new OpenLayers.Strategy.Fixed()],
    protocol: new OpenLayers.Protocol.WFS
		({
		    url: "http://localhost:8080/geoserver/wfs",
		    featureType: "table_1",
		    featurePrefix: 'topp',
		    featureNS: "http://www.openplans.org/topp",
		    maxFeatures: 100
		})
});

2) getfeature

var control = new OpenLayers.Control.GetFeature
    ({
        protocol: OpenLayers.Protocol.WFS ({
    url: "http://localhost:8080/geoserver/wfs",
    featureType: "table_1",
    featurePrefix: 'topp',
    featureNS: "http://www.openplans.org/topp",
    geometryName: 'the_geom',
    maxFeatures: 100
})
    });


3) getfeature event

    control.events.register("featureselected", this, function (e) {
            alert(e.feature.data.name);
    });



The code is working fine so far. the user is clicking on a wfs entry and the
name is shown in a message-box. but now i want to export the gml, which is
generated with a wfs getfeature, and save it on my pc. is this possible with
openlayers? how do i manage this?


Thanks for your answers.

--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/WFS-getFeature-save-result-as-gml-tp6
858435p6858435.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list