停止谷歌地图标记悬停时指针光标样式?

Eva*_*nss 6 google-maps google-maps-api-3

如何阻止我的谷歌地图标记在悬停时使用指针光标样式?目前,标记的行为类似于链接,如果将鼠标悬停在它们上方,光标将变为手形.

以下是创建标记的代码:

function addMarkerLargeMap(latlng, myTitle, html, price) {
    markers.push(new google.maps.Marker({
        position: latlng, 
        map: map,
        title: myTitle, 
         icon: "path-to-my-icon.png",  
         html: "<div style='width:100px;height:auto'>" + html + "</div>",

      }));
Run Code Online (Sandbox Code Playgroud)

dun*_*can 21

在标记选项中将clickable设置为false

function addMarkerLargeMap(latlng, myTitle, html, price) {
    markers.push(new google.maps.Marker({
        position: latlng, 
        clickable: false,
        map: map,
        title: myTitle, 
         icon: "path-to-my-icon.png",  
         html: "<div style='width:100px;height:auto'>" + html + "</div>",
      }));
Run Code Online (Sandbox Code Playgroud)

或者,cursor如果要使用特定类型的游标而不是默认值,则可以在标记选项中设置属性.例如

cursor: 'crosshair'
Run Code Online (Sandbox Code Playgroud)

虽然只有标记是可点击的,但这似乎才有效.

  • 请记住,设置`clickable:false`将阻止显示`title`(工具提示). (2认同)