Use clone method in kml format
This commit is contained in:
+12
-21
@@ -321,31 +321,22 @@ ol.format.KML.createNameStyleFunction_ = function(foundStyle, name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (foundStyle.getText() !== null) {
|
if (foundStyle.getText() !== null) {
|
||||||
// clone the text style, customizing it with name, alignments and offset.
|
// clone the text style, customizing it with name, alignments and offset.
|
||||||
// Note that kml does not support many text options that OpenLayers does (rotation, textBaseline).
|
// Note that kml does not support many text options that OpenLayers does (rotation, textBaseline).
|
||||||
var foundText = foundStyle.getText();
|
var foundText = foundStyle.getText();
|
||||||
textStyle = new ol.style.Text({
|
textStyle = foundText.clone();
|
||||||
text: name,
|
textStyle.setFont(foundText.getFont() || ol.format.KML.DEFAULT_TEXT_STYLE_.getFont());
|
||||||
textAlign: textAlign,
|
textStyle.setScale(foundText.getScale() || ol.format.KML.DEFAULT_TEXT_STYLE_.getScale());
|
||||||
offsetX: textOffset[0],
|
textStyle.setFill(foundText.getFill() || ol.format.KML.DEFAULT_TEXT_STYLE_.getFill());
|
||||||
offsetY: textOffset[1],
|
textStyle.setStroke(foundText.getStroke() || ol.format.KML.DEFAULT_TEXT_STROKE_STYLE_);
|
||||||
font: foundText.getFont() || ol.format.KML.DEFAULT_TEXT_STYLE_.getFont(),
|
|
||||||
scale: foundText.getScale() || ol.format.KML.DEFAULT_TEXT_STYLE_.getScale(),
|
|
||||||
fill: foundText.getFill() || ol.format.KML.DEFAULT_TEXT_STYLE_.getFill(),
|
|
||||||
stroke: foundText.getStroke() || ol.format.KML.DEFAULT_TEXT_STROKE_STYLE_
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
textStyle = new ol.style.Text({
|
textStyle = ol.format.KML.DEFAULT_TEXT_STYLE_.clone();
|
||||||
text: name,
|
|
||||||
offsetX: textOffset[0],
|
|
||||||
offsetY: textOffset[1],
|
|
||||||
textAlign: textAlign,
|
|
||||||
font: ol.format.KML.DEFAULT_TEXT_STYLE_.getFont(),
|
|
||||||
scale: ol.format.KML.DEFAULT_TEXT_STYLE_.getScale(),
|
|
||||||
fill: ol.format.KML.DEFAULT_TEXT_STYLE_.getFill(),
|
|
||||||
stroke: ol.format.KML.DEFAULT_TEXT_STROKE_STYLE_
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
textStyle.setText(name);
|
||||||
|
textStyle.setOffsetX(textOffset[0]);
|
||||||
|
textStyle.setOffsetY(textOffset[1]);
|
||||||
|
textStyle.setTextAlign(textAlign);
|
||||||
|
|
||||||
var nameStyle = new ol.style.Style({
|
var nameStyle = new ol.style.Style({
|
||||||
text: textStyle
|
text: textStyle
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user