Skip to content

How to make Google Map Marker non clickable

If you have been working with Google map markers for a long time, you probably know that whatever map marker you place on the map is clickable by default. But what if I need a non-clickable marker? Easy, its in the Google Maps API. Yes it is, but the documentation is not very straight forward.

Taking a look at the GMarker section in the Google Maps API, we realise that the constructor takes two arguments. GLatLng and GMarkerOptions. What we need is the GMarkerOptions, which specifies the map marker options. Taking a look at the GMarkerOptions, we see that the class has no constructor. It only has a list of properties. Among, the clickable property.

But how do we use those properties? A little bit of googling around gave me answer. It was found on the Official Google Maps API Blog. The solution is pretty simple. Just take a look on the code below and you will see what I mean.

var markerOptions = {
clickable: false
var marker = new GMarker(new GLatLng(37.4419,-122.1419), markerOptions);

As you can see, the code is very simple, but the documentation is not precise enough. Hope this helps you out. Just a note, map marker options should be separated by a comma.

Published inCoding