3
OpenLayers中的默認標籤3.10.1標籤MultiPolygon的每個部分。我想知道是否可以只標註MultiPolygon中的第一個多邊形。將MultiPolygon特徵的標籤限制爲一個標籤
OpenLayers中的默認標籤3.10.1標籤MultiPolygon的每個部分。我想知道是否可以只標註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({...})
})
];
真是太好了! '+ 1' ...因此不喜歡'+ 1'。 –
工程就像一個魅力!真棒。 – Enzo
不適合我。它集中在多面體內的一個多邊形上。如果我將它更改爲'return interiorPoints.getPoint(1);'它以另一個多邊形爲中心。我怎樣才能讓它集中在多面體上? –