首页 / 浏览问题 / 云GIS / 问题详情
openlayers 文字标注发生重叠时如何自动控制显影?
64EXP 2019年10月14日
使用产品: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);

1个回答

你好,layer图层设置declutter属性即可。该属性是整理图像与文字。
1,686EXP 2019年10月14日
...