Google Maps HeatmapLayer可点击的端点 [英] Google Maps HeatmapLayer clickable endpoints

查看:94
本文介绍了Google Maps HeatmapLayer可点击的端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户达到缩放级别时,群集仅由1-4个LatLng点组成,我想使对象可单击以显示用于热图的数据源. 有关如何解决此问题的任何提示? 我可以将任何类型的EventListener连接到HeatmapLayer点吗?

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?

推荐答案

热图没有点击事件(基本上没有热图会监听的事件).

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

您可以做什么:使用markerClusterer.

What you can do: use a markerClusterer.

为所有点创建标记,因为markerImage会分配一个透明图像(大小应该为15x15),然后将所需的点击事件应用于标记.

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.

将标记放入 markerClusterer 并将以下样式应用于群集器:

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
  }

结果:

只要标记聚集在一起,您将看不到任何东西.

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.

这篇关于Google Maps HeatmapLayer可点击的端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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