From daa970fe4c9ad21f7813664412a75059f94c2b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 4 Nov 2015 16:07:29 +0100 Subject: [PATCH] =?UTF-8?q?Make=20KML=C2=A0format=20ignore=20image=20style?= =?UTF-8?q?s=20that=20aren't=20icons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ol/format/kmlformat.js | 2 +- test/spec/ol/format/kmlformat.test.js | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/ol/format/kmlformat.js b/src/ol/format/kmlformat.js index 3e1e4c39a8..b8aa839c8b 100644 --- a/src/ol/format/kmlformat.js +++ b/src/ol/format/kmlformat.js @@ -2509,7 +2509,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 007c53c840..c56c5f16d8 100644 --- a/test/spec/ol/format/kmlformat.test.js +++ b/test/spec/ol/format/kmlformat.test.js @@ -1801,6 +1801,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({ @@ -2747,6 +2773,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');