ngplayground
ngplayground

Reputation: 21667

Google Maps API V3 change Marker Option

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

Upvotes: 1

Views: 6181

Answers (2)

ngplayground
ngplayground

Reputation: 21667

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

marker.setClickable (true);

Upvotes: 1

Adam Jenkins
Adam Jenkins

Reputation: 55792

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

marker.setOptions({clickable:false});

Upvotes: 1

Related Questions