diff --git a/src/ol/format/kmlformat.js b/src/ol/format/kmlformat.js index d9edd33d54..9c55d8ceac 100644 --- a/src/ol/format/kmlformat.js +++ b/src/ol/format/kmlformat.js @@ -2512,7 +2512,7 @@ ol.format.KML.writeStyle_ = function(node, style, objectStack) { var strokeStyle = style.getStroke(); var imageStyle = style.getImage(); var textStyle = style.getText(); - if (imageStyle) { + if (imageStyle instanceof ol.style.Icon) { properties['IconStyle'] = imageStyle; } if (textStyle) { diff --git a/test/spec/ol/format/kmlformat.test.js b/test/spec/ol/format/kmlformat.test.js index 72c642de83..440df02a3a 100644 --- a/test/spec/ol/format/kmlformat.test.js +++ b/test/spec/ol/format/kmlformat.test.js @@ -1804,6 +1804,32 @@ describe('ol.format.KML', function() { expect(node).to.xmleql(ol.xml.parse(text)); }); + it('skips image styles that are not icon styles', function() { + var style = new ol.style.Style({ + image: new ol.style.Circle({ + radius: 4, + fill: new ol.style.Fill({ + color: 'rgb(12, 34, 223)' + }) + }) + }); + var feature = new ol.Feature(); + feature.setStyle([style]); + var node = format.writeFeaturesNode([feature]); + var text = + '' + + ' ' + + ' ' + + ' ' + + ''; + expect(node).to.xmleql(ol.xml.parse(text)); + }); + it('can write an feature\'s text style', function() { var style = new ol.style.Style({ text: new ol.style.Text({ @@ -2750,6 +2776,7 @@ goog.require('ol.geom.MultiPoint'); goog.require('ol.geom.MultiPolygon'); goog.require('ol.geom.Point'); goog.require('ol.geom.Polygon'); +goog.require('ol.style.Circle'); goog.require('ol.style.Fill'); goog.require('ol.style.Icon'); goog.require('ol.style.IconOrigin');