使用产品:iserver 810 操作系统:win10 x64
数据类型: oracle 11g x64
问题详细描述:openlayers 地图添加文字标注发生重叠时如何自动隐藏,地图放大到不重叠时显示?
var createLabelStyle = function(feature) {
return new ol.style.Style({
text: new ol.style.Text({
textAlign: 'left',
textBaseline: 'middle',
font: 'normal 10px 微软雅黑',
text: feature.get('name'),
fill: new ol.style.Fill({
color: '#aa3300'
}),
stroke: new ol.style.Stroke({
color: '#ffcc33',
width: 1
})
})
});
}
var iconFeatures = [];
for (var i = 0; i < this.TPBZMarkArr.length; i++) {
//实例化Vector要素,通过矢量图层添加到地图容器中
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point(this.TPBZMarkArr[i]),
name: this.oilFieldName[i]
});
iconFeature.setStyle(createLabelStyle(iconFeature));
iconFeatures.push(iconFeature);
}
//矢量标注的数据源
var vectorSource = new ol.source.Vector({
features: iconFeatures
});
//矢量标注图层
var vectorLayer = new ol.layer.Vector({
source: vectorSource
});
this.map.addLayer(vectorLayer);