DomIcon的聚类 [英] Clustering for DomIcon

查看:58
本文介绍了DomIcon的聚类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建 H.map.DomMarker 的群集,这些群集将 H.map.DomIcon 与HTML代码一起使用.但是原生的Here Map聚类无法正常工作.仅当我使用简单的 H.map.Icon ,但由于它呈现为 canvas 图层时,我才能使用自己的标记.

I am trying to make clusters of H.map.DomMarker, which are using H.map.DomIcon with the HTML code. But the native Here Map clustering doesn't work. Only if I use simple H.map.Icon, but as this is rendered as a canvas layer, I cannot use my own markers.

有什么方法可以在 DomIcon 上获取群集吗?

Is there any way how to get clusters on DomIcon?

另外,有什么方法可以获取群集内的标记列表吗?

Also, is there any way how to get list of markers inside cluster?

谢谢丹

推荐答案

使用

This should be possible using the code from Map clustering with custom theme, because the clustering itself is agnostic to the resulting icon.

该示例中群集的第一个关键部分是创建一个 H.clustering.DataPoint(item.latitude,item.longitude,null,item)的集合,其中包含lat,lon.聚类基于这些坐标和算法配置.另一个关键部分是主题本身,其中包含两个函数定义:

The first key part of the clustering in the example is to create a collection of H.clustering.DataPoint(item.latitude, item.longitude, null, item) which contains lat, lon. The clustering is based on those coordinates, and on the algorithm configuration. The other key part is the theme itself which contains two function definitions:

  • getClusterPresentation ,它负责返回聚集在一起的点的 H.map.Marker
  • getNoisePresentation ,它负责返回非聚集点的 H.map.Marker
  • getClusterPresentation which is responsible for returning the H.map.Marker of points clustered together
  • getNoisePresentation which is responsible for returning the H.map.Marker of non clustered points

由于 H.map.DomMarker H.map.Marker ,因此上述两个函数应返回 H.map.DomMarker 工作.

Since H.map.DomMarker is a H.map.Marker, having the two above functions returning H.map.DomMarker should work.

有什么方法可以获取群集内的标记列表

Is there any way how to get list of markers inside cluster

是的.当为集群创建标记时,在 getClusterPresentation 中,您将获得聚集在一起的点(请参见 cluster.forEachDataPoint 函数).之前,当您创建数据点时,您就有机会在其中存储数据.因此,现在是从这些聚集在一起的数据点中获取数据,并在必要时在聚集标记中引用它的好时机.

Yes. When you create the marker for the cluster, in getClusterPresentation, you get the points which are being clustered together (see cluster.forEachDataPoint function). And before, when you create the datapoints, you had the chance to store data in it. So it is a good time to get data from those datapoints being clustered together, and reference it in the cluster marker if necessary.

希望有道理!

另外

[...]如果我使用简单的H.map.Icon,但是由于它呈现为画布层,则不能使用自己的标记

[...] if I use simple H.map.Icon, but as this is rendered as a canvas layer, I cannot use my own markers

实际上,您可以使用 H.map.Icon 和在画布中呈现的标记来完成上述所有操作.不过,有些事情不太明显,例如,将鼠标悬停在群集或噪声点上时设置指针光标.

Actually you can do all of the above with H.map.Icon and markers rendered in the canvas. Some things are a bit less obvious though, like setting a pointer cursor when hovering on a cluster or a noisepoint.

这篇关于DomIcon的聚类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆