1

I would like to use OpenLayers 3 to write GML features.

Here is my code:

proj4.defs("EPSG:25833", "+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");

prjCrs.epsg25832 = ol.proj.get('EPSG:25832');
prjCrs.epsg4326 = 'EPSG:4326';


var features = digitizingVector.getSource().getFeatures();

var format = new ol.format.GML();
var out = format.writeFeatures(features, {
    dataProjection: prjCrs.epsg4326,
    featureProjection: prjCrs.epsg25832
});

However, this always spits out the following error message:

ol.js:357 Uncaught TypeError: Cannot read property 'undefined' of undefined


With ol-debug.js the following error message is returned:

enter image description here

I am using the exact same logic to write features in GeoJSON, KML, GPX, WKT and it works perfecty fine. Is there an issue with GML features in OpenLayers 3?

I am using version 3.19.1 of OpenLayers.

2
  • What is the error message when using ol-debug.js ?
    – bartvde
    Jan 10, 2017 at 10:45
  • Thank you, I have updated my question accordingly. I also mentioned that I am using version 3.19.1. Jan 10, 2017 at 11:02

1 Answer 1

2

When writing out GML you need to provide some extra config in the constructor of the format, probably featureType, featureNS and srsName.

2
  • That worked! All of the above had to be entered: featureNS, featureType, srsName. Jan 11, 2017 at 9:09
  • What surprise me is that featureNS, featureType and srsName are optional but there is an error in JS if there are not defined. Sep 3, 2020 at 13:02

Your Answer

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

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