Is there a way to programmatically change the geometry column on which a WFS layer is based and displayed?

WFS (from GeoServer) is correctly returning me two geometry columns, I want to change "on the fly" the geometry column OpenLayers uses to display items, obviously having OpenLayers displaying items (points, in this case) at the new coordinates.

I already tried to change the protocol.geometryName field, even forcing reload to refresh on the layer, but without success.

  • could you post a code snippet?. Also two geometry column means you are having two geom types in single layer?.
    – rkm
    Commented Sep 27, 2013 at 7:32

2 Answers 2


Changing the geometryName property won't have any effect, because the geometry field is defined in the geoServer layer.

Create two views which expose each geometry column:

See here for an example.

Then create layers in geoserver on each view.

You can then programmatically change the source layer name in your WFS layer source and call refresh().


Why do you want to do this? Are they in two different projections?

May be easier to use WMS rather than WFS

Create two WMS layers, using one geometry in each layer only, then just pick a layer client side and disable the other one. (Toggle between them)

The client will only pick from the layer it sees for WFS requests, for hover, etc.



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.