0

我已经创建了开放图层地图并使用一些动态纬度和经度在地图中设置标记,一些纬度和经度值是相同的,所以单击标记时如何打开蜘蛛视图

   let path = this.props.waypts;

        path.map((lat,index)=>{
            let fill = new style.Fill({color:'rgba(255,255,255,1)'}),
            stroke = new style.Stroke({color:'rgba(0,0,0,1)'}),
            style1 = [
                new style.Style({
                    image: new style.Icon(({
                        scale: .9, 
                        opacity: 1,
                        rotateWithView: false, 
                        anchor: [0.5, 1],
                        anchorXUnits: 'fraction', 
                        anchorYUnits: 'fraction',
                        src: "https://img.icons8.com/metro/40/"+(this.props.color[index]).replace( /#/g, "" )+"/marker.png"
                    })),
                    zIndex: 5
                }),
                new style.Style({
                    image: new style.Circle({
                        radius: 6, 
                        fill: fill, 
                        stroke: stroke
                    }),
                    zIndex: 4
                })
            ];

            let abc = 'feature'+[index+1];               
            abc = new Feature({
                geometry: new geom.Point(path[index])
            });
            abc.setStyle(style1);
            sourceFeatures.addFeatures([abc]);
        })

        map.getView().fit(sourceFeatures.getExtent(), map.getSize()); 
4

1 回答 1

0

看看 ol-ext 中的 ol/interaction/SelectCluster。在选择时,簇会弹开以显示其中的特征。在线查看示例:https ://viglino.github.io/ol-ext/examples/animation/map.animatedcluster.html

在此处输入图像描述

于 2020-01-26T20:33:12.507 回答