Albert Ang
Albert Ang

Reputation: 15

Google map api v3, how to add polygons to custom overlay

The following site : https://developers.google.com/maps/documentation/javascript/customoverlays shows how to create image overlay using customoverlays but how do I use the same technique for creating polygons using customoverlays. The map that I am using comes from the following example http://gmaps-samples-v3.googlecode.com/svn/trunk/latlng-to-coord-control/latlng-to-coord-control.html . However, when I added polygons to the map, it is unable to display lat/long/pixel values when I moved the mouse over the polygons. I thought that if I created the polygons using custom overlays the problems will be solved. I have created image overlays using custom overlays and it is able to display the correct lat/lng/pixel values when I moved the mouse over the image. Therefore I think if I create the polygons using custom overlays, it should work also but I could not find examples on how to do that. Please advise.

Updated Code:

aoiPoly = new google.maps.Polygon({ 
  paths: polyCoords, 
  strokeColor: '#FF0000', 
  strokeOpacity: 0.8, 
  strokeWeight: 2, 
  fillColor: '#FF0000', 
  fillOpacity: 0.35, 
  clickable:false 
}); 
aoiPoly.setMap(map);

Upvotes: 1

Views: 1567

Answers (1)

geocodezip
geocodezip

Reputation: 161334

If you set clickable:false on the google.maps.Polygons, they will be prevented from intercepting the mouse events.

clickable | boolean | Indicates whether this Polygon handles mouse events. Defaults to true

Upvotes: 1

Related Questions