Make feature styles compatible with declutter
Return a single style object for image and text for point features as concatenating two styles in an array is not compatible with decluttering
This commit is contained in:
@@ -911,9 +911,8 @@ function createNameStyleFunction(foundStyle, name) {
|
||||
textStyle.setOffsetY(textOffset[1]);
|
||||
textStyle.setTextAlign(textAlign);
|
||||
|
||||
const nameStyle = new Style({
|
||||
text: textStyle
|
||||
});
|
||||
const nameStyle = foundStyle.clone();
|
||||
nameStyle.setText(textStyle);
|
||||
return nameStyle;
|
||||
}
|
||||
|
||||
@@ -932,12 +931,11 @@ function createFeatureStyleFunction(style, styleUrl, defaultStyle, sharedStyles,
|
||||
/**
|
||||
* @param {Feature} feature feature.
|
||||
* @param {number} resolution Resolution.
|
||||
* @return {Array<Style>} Style.
|
||||
* @return {Array<Style>|Style} Style.
|
||||
*/
|
||||
function(feature, resolution) {
|
||||
let drawName = showPointNames;
|
||||
/** @type {Style|undefined} */
|
||||
let nameStyle;
|
||||
let name = '';
|
||||
if (drawName) {
|
||||
const geometry = feature.getGeometry();
|
||||
@@ -953,22 +951,19 @@ function createFeatureStyleFunction(style, styleUrl, defaultStyle, sharedStyles,
|
||||
|
||||
if (style) {
|
||||
if (drawName) {
|
||||
nameStyle = createNameStyleFunction(style[0], name);
|
||||
return style.concat(nameStyle);
|
||||
return createNameStyleFunction(style[0], name);
|
||||
}
|
||||
return style;
|
||||
}
|
||||
if (styleUrl) {
|
||||
const foundStyle = findStyle(styleUrl, defaultStyle, sharedStyles);
|
||||
if (drawName) {
|
||||
nameStyle = createNameStyleFunction(foundStyle[0], name);
|
||||
return foundStyle.concat(nameStyle);
|
||||
return createNameStyleFunction(foundStyle[0], name);
|
||||
}
|
||||
return foundStyle;
|
||||
}
|
||||
if (drawName) {
|
||||
nameStyle = createNameStyleFunction(defaultStyle[0], name);
|
||||
return defaultStyle.concat(nameStyle);
|
||||
return createNameStyleFunction(defaultStyle[0], name);
|
||||
}
|
||||
return defaultStyle;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user