在 Google Maps JS API 中禁用 POI 标记的点击行为 [英] Disable click behavior of POI markers in Google Maps JS API

查看:22
本文介绍了在 Google Maps JS API 中禁用 POI 标记的点击行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从 Google Maps API v3.6 开始,地图现在包含兴趣点",即嵌入到地图中的灰色标记.当用户点击此图标时,会出现一个信息窗口,其中包含有关该企业(或公园、医院等)的信息

As of Google Maps API v3.6, maps now include "points of interest", which are gray markers embedded into a map. When the user clicks on this icon, an InfoWindow appears with information about that business (or park, hospital, etc.)

这些可以通过设置样式来关闭.(参见样式数组示例")

These can be turned off by setting the Styling. (See "Style Array Example")

https://code.google.com/apis/maps/documentation/javascript/styling.html

一旦关闭,图标、名称和阴影区域(公园和医院)就会消失.

Once they are turned off, the icons, names, and shaded regions (for parks and hospitals) go away.

在 Google Maps API v3.6 之前,没有图标;只有名称和地区.

Before Google Maps API v3.6, there were no icons; only the names and regions.

问题:有没有办法去除这些兴趣点的点击图标打开信息窗口"行为?我还是想保留图标、名称和区域;只想删除点击行为.

The question: is there a way to remove the "click icon to open info window" behavior of these points of interest? I still want to keep the icons, names, and regions; only want to remove the click behavior.

替代问题:有没有办法下载/保存 Google Maps API v3.5 的 JavaScript 以存储在我的服务器上?目前,v3.5 可以很好地满足我的需要.2 月份,Google 将不再提供 v3.5 的代码,而是仅提供 v3.6、v3.7、v3.8.

Alternate question: is there a way to download/save the JavaScript of the v3.5 of Google Maps API to store on my server? At present, v3.5 is working fine for what I need. In February, Google will no longer provide v3.5 of the code and will instead provide only v3.6, v3.7, v3.8.

停用 Google Maps API v3 的次要版本,并使用 API 的冻结"版本:

Retiring of minor versions of Google Maps API v3, and using the "frozen" version of an API:

https://code.google.com/apis/maps/documentation/javascript/basics.html#Versioning

我尝试并考虑的事情: 在点击地图时添加事件侦听器不起作用,因为点击的是嵌入的标记而不是地图.添加clickable: false"作为属性是在黑暗中拍摄,没有结果.设置visiblility: off"会将其全部删除,从而使地图的内容更少.设置可见性:简化"会删除位置的名称,但仍然存在点击行为.在地图上放置一个不可见的 DIV 可能会起作用,但它会移除平移/缩放/拖动地图的能力,而不会增加复杂性.

Things I've tried and considered: Adding an event listener when the map is clicked does not work, because the embedded markers are clicked instead of the map. Adding "clickable: false" as a property was a shot in the dark, with no result. Setting "visiblility: off" removes it all, leaving the map with less content. Setting "visibility: simplified" removes the name of the location, though the onclick behavior is still present. Putting an invisible DIV overlaying the map might work, though it would remove the ability to pan/zoom/drag the map without increasing complexity.

设置样式,使 featureType: poi, elementType: labels, visible: off 将导致显示医院/墓地/公园的粉红色/灰色/绿色区域,没有标记或名称.它会为地图返回更多颜色.

Setting a style so that featureType: poi, elementType: labels, visibility: off will result in showing the pink/gray/green regions for hospitals/cemeteries/parks, without the marker or name. It returns more color to the map.

推荐答案

我不确定这是否仍然与您相关,但 Google 确实在 2016 年 4 月解决了该问题,您需要做的就是clickableIcons 到 MapOptions 中的 false

I'm not sure if this is still relevant to you, but Google did, indeed, solve the issue on April, 2016, all you need to do is clickableIcons to false in MapOptions

这篇关于在 Google Maps JS API 中禁用 POI 标记的点击行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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