openlayers 文字标注发生重叠时如何自动控制显影?

0 投票
使用产品: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);
10月 14 分类:  75次浏览 | 用户: 吕峥嵘 初出茅庐 (49 分)
重新分类 10月 14 用户:邬袁凯

1个回答

0 投票
你好,layer图层设置declutter属性即可。该属性是整理图像与文字。
10月 14 用户: 李俊霖 才高八斗 (994 分)
...