gpt4 book ai didi

openlayers-3 - 将 MultiPolygon 特征的标签限制为一个标签

转载 作者:行者123 更新时间:2023-12-04 23:18:37 27 4
gpt4 key购买 nike

OpenLayers 3.10.1 中的默认标签标记 MultiPolygon 的每个部分。我想知道是否可以只标记 MultiPolygon 中的第一个多边形。

最佳答案

您可以为带有 geometry function 的标签使用单独的样式。 ,它返回标签位置的单个点。

var styles = [
// Style for the label
new ol.style.Style({
text: new ol.style.Text({..}),
geometry: function(feature) {
// expecting a MultiPolygon here
var interiorPoints = feature.getGeometry().getInteriorPoints();
return interiorPoints.getPoint(0);
}
}),
// Style for the polygons
new ol.style.Style({
stroke: new ol.style.Stroke({...}),
fill: new ol.style.Fill({...})
})
];

http://jsfiddle.net/p0acpbtg/2/

关于openlayers-3 - 将 MultiPolygon 特征的标签限制为一个标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33484283/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com