Google Maps API V3更改标记选项 [英] Google Maps API V3 change Marker Option

查看:109
本文介绍了Google Maps API V3更改标记选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

marker = new google.maps.Marker({
    icon: image,
    position: new google.maps.LatLng(locations[i][1], locations[i][2]),
    flat: true,
    optimized: false,
    map: map,
    visible: true,
    customInfo: locations[i][0]
    });

我有上面的内容可以在我的Google地图中创建标记,但是当点击标记时,地图放大到该位置,我想使标记不可点击。

I have the above to build my Marker in my Google Map but when the marker is clicked, the map zooms to the location and I'd like to make the marker non clickable.

我试过以下成功:

I have tried the following with no success

google.maps.event.addListener(marker, 'click', function() {
    map.setZoom(17);
    map.setCenter(this.getPosition());
    marker.MarkerOptions ({
        clickable: false
    });
});


推荐答案

我发现它,其实相当简单做到这一点。

I found it and its actually quite a simple way of doing it.

marker.setClickable (true);

这篇关于Google Maps API V3更改标记选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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