超级集群:在集群中获取所有标记

发布于 2025-01-31 06:35:52 字数 386 浏览 3 评论 0原文

我正在使用 superclsuter 用于在React Map中进行聚类标记,我想要的是从群集无论嵌套群集的嵌套水平如何。

为了更好地解释情况,一个集群可以在孩子们的时候有标记和其他簇,我需要弄平孩子簇以在其中获取标记。

cluster
  marker
  cluster(3 markers)

// this should return the 4 markers, the top-level marker, and markers within the child cluster

I'm using superclsuter for clustering markers in react native map, what I want is to get all children from a cluster no matter what level of nesting a cluster may have.

to explain the situation a little better, a cluster can have markers and other clusters as children, I need to flatten the child clusters to get markers inside them.

cluster
  marker
  cluster(3 markers)

// this should return the 4 markers, the top-level marker, and markers within the child cluster

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不如归去 2025-02-07 06:35:52

我知道答案很晚,但是此解决方案是使用Google-map-react软件包用于Google Map的。

  1. 首先初始化地图选项,添加maxzoom和minzoom。 Maxzoom必须等于超级集群Max-Zoom

  2. 使用此代码:

    if(iscluster){

      if(zoom> = 15){
        返回 (
            //创建类似于以下标记的多标记,但不同的InfowDindow样式显示位置列表并显示文本
            < multimarker
                key = {`cluster-$ {cluster.id}`}
                lat = {纬度}
                lng = {经度}
                text = {$ {pointCount} listing`}
                place = {supercluster.getChildren(cluster.id)}
            >
            </multimarker>
        )
    }别的{
        返回clustermarker;
    }
     

    }

    返回普通或自定义标记;

对于群集参考: https://www.leighhalliday.com/google-maps-maps-clustering

I know it is late for an answer, but this solution is for google map using google-map-react package.

  1. First on initializing the map options, add maxZoom and minZoom. maxZoom must be equal to supercluster max-zoom

  2. On cluster rendering use this code:

    if(isCluster){

    if(zoom>=15){
        return (
            //Create MultiMarker similar to the marker below but different infowindow style to display list of places and display text
            <MultiMarker
                key={`cluster-${cluster.id}`}
                lat={latitude}
                lng={longitude}
                text={`${pointCount} Listing`}
                places={supercluster.getChildren(cluster.id)}
            >
            </MultiMarker>
        )
    }else{
        return ClusterMarker;
    }
    

    }

    return Normal or Custom marker;

For cluster reference: https://www.leighhalliday.com/google-maps-clustering

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文