Clustering for DomIcon

十年热恋 提交于 2021-02-10 13:46:09

问题


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.

Is there any way how to get clusters on DomIcon?

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

Thanks Dan


回答1:


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

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 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

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

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.

Hope it makes sense!

Additionally

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

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.



来源:https://stackoverflow.com/questions/52724857/clustering-for-domicon

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!