AngularUI: Mouseover event for Google maps markers

February 20, 2015

The problem:

It took me awhile to figure this out, so I think it probably deserves a blog post to explain the issue. I was a bit confused on how to hookup the mouseover events with google map markers and the AngularUI documentation is pretty vague about how to do that. It is only supported for a marker, not for markers.

For a single marker, it is intuitive to specify a directive with events property in the HTML:

And then in the controller,

$scope.marker = { events: { mouseover: function (marker, eventName, args) { // Callback } } };

However, it doesn’t work the same for multiple markers. I couldn’t simply add mouseover events on each marker like this:

markers.push({ events: { mouseover : function(mapModel, eventName, originalEventArgs) { console.log(“i’d really like to show the info window on mouseover”); } } });

My Solutions:

Add the following to the HTML markers directive:


And in the controller:

$scope.clickEventsObject = { mouseover: markerMouseOver, mouseout: markerMouseOut };

function markerMouseOver(marker, e) { //Callback }

function markerMouseOut(marker, e) { //Callback }

It works! This handler returns a directly mapped array of the models which belong to gMarker cluster sent along. Let me know if you have any questions

Originally published at on January 6, 2015.

Written by Victor Leung who is a keen traveller to see every country in the world, passionate about cutting edge technologies. Follow me on Twitter