Google Maps HeatmapLayer clickable endpoints

徘徊边缘 提交于 2019-12-09 03:36:23

问题


When a user reaches a zoom level where the cluster only consist of 1-4 LatLng points I would like to make the object clickable to show source of the data used for the heatmap. Any tips on how to address this issue? Can I connect any type of EventListener to the HeatmapLayer points?


回答1:


There is no click-event for a heatmap( basically there isn't any event a heatmap will listen to).

What you can do: use a markerClusterer.

Create Markers for all points, as markerImage assign a a transparent image(a size of 15x15 should be fine) and apply the desired click-event to the marker.

Push the markers into a markerClusterer and apply the following style to the clusterer:

  {
    url: 'path/to/transparentImage.png',
    height: 0,
    width: 0,
    textColor: 'transparent',
    textSize: 0
  }

Result:

as long as the markers are clustered, you'll not see anything.

When a marker isn't clustered anymore, you'll also not see anything(because the marker is transparent), but you can click on the transparent marker, and the marker will respond to the click.



来源:https://stackoverflow.com/questions/14290962/google-maps-heatmaplayer-clickable-endpoints

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