简体   繁体   English

防止 Google 地图标记可点击

[英]Prevent Google map marker from being clickable

I would like to know if there's a way to prevent a Google map marker from being clickable.我想知道是否有办法防止 Google 地图标记被点击。 I thought this is something that could be set up in the map options using the following code.我认为这可以使用以下代码在地图选项中设置。

map_options: {        
    clickable: false,
},  

I found this in a really old blog post:我在一篇非常古老的博客文章中发现了这一点:

http://www.technoreply.com/how-to-make-google-map-marker-non-clickable/ http://www.technoreply.com/how-to-make-google-map-marker-non-clickable/

However I'm not sure if this option has been deprecated or not.但是,我不确定此选项是否已被弃用。

To prevent a marker from being clickable, set its clickable property to false (won't make much difference if you don't have something to handle the click event, except prevent the cursor from changing).要防止标记可点击,请将其clickable属性设置为 false(如果您没有处理点击事件的内容,则不会有太大区别,除非防止光标更改)。

 function initialize() { var map = new google.maps.Map( document.getElementById("map_canvas"), { center: new google.maps.LatLng(37.4419, -122.1419), zoom: 13, mapTypeId: google.maps.MapTypeId.ROADMAP }); var marker = new google.maps.Marker({ map: map, position: map.getCenter(), clickable: false }); } google.maps.event.addDomListener(window, "load", initialize);
 html, body, #map_canvas { height: 100%; width: 100%; margin: 0px; padding: 0px }
 <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script> <div id="map_canvas"></div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM