From 2b6e767840292db180d7312aae23db68497e021c Mon Sep 17 00:00:00 2001 From: Jiri Lysek Date: Mon, 23 Mar 2020 10:10:12 +0100 Subject: [PATCH] encoding color into KML --- src/ol/format/KML.js | 8 +++++++- test/spec/ol/format/kml.test.js | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ol/format/KML.js b/src/ol/format/KML.js index 2833548651..88b69bbc98 100644 --- a/src/ol/format/KML.js +++ b/src/ol/format/KML.js @@ -2452,7 +2452,7 @@ function writeIcon(node, icon, objectStack) { // @ts-ignore const ICON_STYLE_SEQUENCE = makeStructureNS( NAMESPACE_URIS, [ - 'scale', 'heading', 'Icon', 'hotSpot' + 'scale', 'heading', 'Icon', 'color', 'hotSpot' ]); @@ -2464,6 +2464,7 @@ const ICON_STYLE_SEQUENCE = makeStructureNS( const ICON_STYLE_SERIALIZERS = makeStructureNS( NAMESPACE_URIS, { 'Icon': makeChildAppender(writeIcon), + 'color': makeChildAppender(writeColorTextNode), 'heading': makeChildAppender(writeDecimalTextNode), 'hotSpot': makeChildAppender(writeVec2), 'scale': makeChildAppender(writeScaleTextNode) @@ -2519,6 +2520,11 @@ function writeIconStyle(node, style, objectStack) { properties['heading'] = rotation; // 0-360 } + const color = style.getColor(); + if (color) { + properties['color'] = color; + } + const parentNode = objectStack[objectStack.length - 1].node; const orderedKeys = ICON_STYLE_SEQUENCE[parentNode.namespaceURI]; const values = makeSequence(properties, orderedKeys); diff --git a/test/spec/ol/format/kml.test.js b/test/spec/ol/format/kml.test.js index 7adedfc2c8..7369705db5 100644 --- a/test/spec/ol/format/kml.test.js +++ b/test/spec/ol/format/kml.test.js @@ -2394,7 +2394,8 @@ describe('ol.format.KML', function() { rotation: 45, scale: 0.5, size: [48, 48], - src: 'http://foo.png' + src: 'http://foo.png', + color: 'rgba(255,0,0,1)' }) }); const imageStyle = style.getImage(); @@ -2420,6 +2421,7 @@ describe('ol.format.KML', function() { ' 48' + ' 48' + ' ' + + ' ff0000ff' + ' ' + ' ' +