diff --git a/src/ol/format/gmlformat.js b/src/ol/format/gmlformat.js index 64cdafd139..58959fcce5 100644 --- a/src/ol/format/gmlformat.js +++ b/src/ol/format/gmlformat.js @@ -137,7 +137,7 @@ ol.format.GML.prototype.readGeometryFromNode = function(node) { */ ol.format.GML.prototype.readFeature_ = function(node, objectStack) { var n; - var values = {}; + var values = {}, geometryName; for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) { // Assume attribute elements have one child node and that the child @@ -147,10 +147,15 @@ ol.format.GML.prototype.readFeature_ = function(node, objectStack) { n.firstChild.nodeType === 3)) { values[ol.xml.getLocalName(n)] = ol.xml.getAllTextContent(n, false); } else { - values[ol.xml.getLocalName(n)] = this.readGeometryFromNode(n); + geometryName = ol.xml.getLocalName(n); + values[geometryName] = this.readGeometryFromNode(n); } } - return new ol.Feature(values); + var feature = new ol.Feature(values); + if (goog.isDef(geometryName)) { + feature.setGeometryName(geometryName); + } + return feature; }; diff --git a/test/spec/ol/format/gmlformat.test.js b/test/spec/ol/format/gmlformat.test.js index 76bff9cf65..55ffa57423 100644 --- a/test/spec/ol/format/gmlformat.test.js +++ b/test/spec/ol/format/gmlformat.test.js @@ -592,7 +592,7 @@ describe('ol.format.GML', function() { it('creates a polygon for Illinois', function() { feature = features[0]; expect(feature.get('STATE_NAME')).to.equal('Illinois'); - expect(feature.get('the_geom')).to.be.an(ol.geom.MultiPolygon); + expect(feature.getGeometry()).to.be.an(ol.geom.MultiPolygon); }); });