Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I customize the behavior of the base Google Map's place markers?

I've been working with the Google Maps API, and while I can add and customize my own markers and info windows, the base map has these default markers that display these info windows when clicked (picture below).

Is there any way to remove this behavior or implement my own (to make them more consistent with the behavior of markers my application adds) when clicking on these locations?

For example, it'd be nice to do be able to add my own marker upon clicking these markers. Something like:

defaultMarker.addListener("click", function () {
    myMarker = new google.maps.Marker({ ... });
});

Except... I don't know of a way to grab these default markers.

Apologies if this has been answered before, or if I've just missed something basic entirely, but I couldn't find any documentation about these "default markers", for lack of better terminology.

Google Maps Default Marker and InfoWindow

like image 929
U-DON Avatar asked Dec 24 '22 05:12

U-DON


1 Answers

The current release version 3.24 of Maps JavaScript API has a property clickableIcons in the Map Options object:

https://developers.google.com/maps/documentation/javascript/reference#MapOptions

You can use this property to turn off clickable icons on maps by setting the clickableIcons property to false. Also exists a setClickableIcons() method.

Please look at this example: http://jsbin.com/liyamecoqa/edit?html,output

like image 156
xomena Avatar answered Feb 16 '23 00:02

xomena