You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you write a kml with a label that has 2 styles,
one for the text, and the other for the custom icon,
the 'name' tag is not written to the output kml.
So, when you want to import it to a map, the label
can not be displayed...
We can resolve it if we modify the code into the class ol.format.KML :
ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
(...)
var styleFunction = feature.getStyleFunction();
if (styleFunction) {
// FIXME the styles returned by the style function are supposed to be
// resolution-independent here
var styles = styleFunction.call(feature, 0);
if (styles) {
var style = Array.isArray(styles) ? styles[0] : styles;
if (this.writeStyles_) {
properties['Style'] = style;
}
// Unnecessary if this property is already filled !
// So it's not necessary to overwrite it...
if (!properties.hasOwnProperty("name")) { // --> the fix is here ! <--
var textStyle = style.getText();
if (textStyle) {
properties['name'] = textStyle.getText();
}
}
}
}
(...)
}
The text was updated successfully, but these errors were encountered:
This little patch does not solve everything,
the ideal would be to have a function to merge styles...
If there are several styles, they are merged to return only one style...
When you write a kml with a label that has 2 styles,
one for the text, and the other for the custom icon,
the 'name' tag is not written to the output kml.
So, when you want to import it to a map, the label
can not be displayed...
You can see the problem :
https://jsfiddle.net/lowzonenose/c9qqbkLz/
We can resolve it if we modify the code into the class ol.format.KML :
The text was updated successfully, but these errors were encountered: