encoding color into KML
This commit is contained in:
@@ -2452,7 +2452,7 @@ function writeIcon(node, icon, objectStack) {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const ICON_STYLE_SEQUENCE = makeStructureNS(
|
const ICON_STYLE_SEQUENCE = makeStructureNS(
|
||||||
NAMESPACE_URIS, [
|
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(
|
const ICON_STYLE_SERIALIZERS = makeStructureNS(
|
||||||
NAMESPACE_URIS, {
|
NAMESPACE_URIS, {
|
||||||
'Icon': makeChildAppender(writeIcon),
|
'Icon': makeChildAppender(writeIcon),
|
||||||
|
'color': makeChildAppender(writeColorTextNode),
|
||||||
'heading': makeChildAppender(writeDecimalTextNode),
|
'heading': makeChildAppender(writeDecimalTextNode),
|
||||||
'hotSpot': makeChildAppender(writeVec2),
|
'hotSpot': makeChildAppender(writeVec2),
|
||||||
'scale': makeChildAppender(writeScaleTextNode)
|
'scale': makeChildAppender(writeScaleTextNode)
|
||||||
@@ -2519,6 +2520,11 @@ function writeIconStyle(node, style, objectStack) {
|
|||||||
properties['heading'] = rotation; // 0-360
|
properties['heading'] = rotation; // 0-360
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const color = style.getColor();
|
||||||
|
if (color) {
|
||||||
|
properties['color'] = color;
|
||||||
|
}
|
||||||
|
|
||||||
const parentNode = objectStack[objectStack.length - 1].node;
|
const parentNode = objectStack[objectStack.length - 1].node;
|
||||||
const orderedKeys = ICON_STYLE_SEQUENCE[parentNode.namespaceURI];
|
const orderedKeys = ICON_STYLE_SEQUENCE[parentNode.namespaceURI];
|
||||||
const values = makeSequence(properties, orderedKeys);
|
const values = makeSequence(properties, orderedKeys);
|
||||||
|
|||||||
@@ -2394,7 +2394,8 @@ describe('ol.format.KML', function() {
|
|||||||
rotation: 45,
|
rotation: 45,
|
||||||
scale: 0.5,
|
scale: 0.5,
|
||||||
size: [48, 48],
|
size: [48, 48],
|
||||||
src: 'http://foo.png'
|
src: 'http://foo.png',
|
||||||
|
color: 'rgba(255,0,0,1)'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
const imageStyle = style.getImage();
|
const imageStyle = style.getImage();
|
||||||
@@ -2420,6 +2421,7 @@ describe('ol.format.KML', function() {
|
|||||||
' <gx:w>48</gx:w>' +
|
' <gx:w>48</gx:w>' +
|
||||||
' <gx:h>48</gx:h>' +
|
' <gx:h>48</gx:h>' +
|
||||||
' </Icon>' +
|
' </Icon>' +
|
||||||
|
' <color>ff0000ff</color>' +
|
||||||
' <hotSpot x="12" y="12" xunits="pixels" ' +
|
' <hotSpot x="12" y="12" xunits="pixels" ' +
|
||||||
' yunits="pixels"/>' +
|
' yunits="pixels"/>' +
|
||||||
' </IconStyle>' +
|
' </IconStyle>' +
|
||||||
|
|||||||
Reference in New Issue
Block a user