Merge pull request #4376 from elemoine/kml-non-icon

Make KML format ignore image styles that aren't icons
This commit is contained in:
Éric Lemoine
2015-11-06 16:46:10 +01:00
2 changed files with 28 additions and 1 deletions

View File

@@ -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) {

View File

@@ -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 =
'<kml xmlns="http://www.opengis.net/kml/2.2"' +
' xmlns:gx="http://www.google.com/kml/ext/2.2"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
' xsi:schemaLocation="http://www.opengis.net/kml/2.2' +
' https://developers.google.com/kml/schema/kml22gx.xsd">' +
' <Placemark>' +
' <Style>' +
' </Style>' +
' </Placemark>' +
'</kml>';
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');