I also need this functionality, but, unfortunately, this is not possible - I'm almost sure (see my demo ). The reason I'm talking is this:
- I tried many different ways, but only the polyline gets the event
- This is not listed in the Google documentation.
which is implied in the following parts of the documentation:
:
A - , .
documenation AddEventListener:
addListener(instance:Object, eventName:string, handler:Function)
. , removeListener().
(, ). , , , . -, .
, , , , . ( : Polyline, ):
var mySymbol = {
path: google.maps.SymbolPath.CIRCLE,
scale: 25,
strokeWeight: 5,
fillOpacity: .2
};
var myPolyline = new google.maps.Polyline({
icons: [{
icon: mySymbol,
fixedRotation: true,
offset: '50%',
}],
path: [polylineCenter, polylineEnd],
strokeColor: 'black',
strokeOpacity: 1,
strokeWeight: 5,
map: myMap
});
google.maps.event.addListener(myPolyline, 'click', function() {
alert('Polyline clicked!');
});
google.maps.event.addListener(mySymbol, 'click', function() {
alert('Symbol clicked!');
});