Google Maps API V3 change Marker Option

浪尽此生 提交于 2019-12-11 13:51:02

问题


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]
    });

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
    });
});

回答1:


Read the documentation - the name of the method you are looking for is called setOptions

marker.setOptions({clickable:false});



回答2:


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

marker.setClickable (true);


来源:https://stackoverflow.com/questions/20953539/google-maps-api-v3-change-marker-option

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!