oym
oym

Reputation: 7083

Google maps api - polygon mouseover

I am using google maps API v3 and have created several polygons on the map. I want the functionality that when the user hovers over a given area (polygon) the individual polygon changes color. Is there any way to do this? (Later I'd like to be able to register mouse events on the given area as well). thanks.

Upvotes: 2

Views: 3215

Answers (2)

jkarpilo
jkarpilo

Reputation: 176

The current polygon object is accessible via this:

google.maps.event.addListener(yourPolygon, 'mouseover', function() {
    var currentPolygon = this;
    currentPolygon.setOptions(...)
});

Upvotes: 2

oym
oym

Reputation: 7083

I managed to figure this out in case anybody else has this issue..

Simply attach an event listener to the polygon object, i.e. mouseover and mouseout events. In the listener simply invoke the setOptions() method on the polygon to set the desired properties.

Upvotes: 1

Related Questions