Reputation: 1384
I have the following code where I initialize a Polygon with an onclick listener that displays an alert:
polygon.location = location;
polygon.locationLabel = new LocationLabel(location, latLng, mapProvider.map);
google.maps.event.addListener(polygon, 'click', function(e) {
alert('hello');
});
This is fine, but displays the alert when I click the Polygon but not the actual Label. How would I add a Listener so that the alert would be displayed just when the label is clicked?
Upvotes: 0
Views: 682
Reputation: 133360
Try with :
textToShow = polygon.locationLabel;
google.maps.event.addListener(polygon, 'click', function(e, textToShow) {
alert(textToShow);
});
Upvotes: 1