Search code examples
google-maps-api-3infowindow

Getting the anchor object of an InfoWindow in Google Maps API v3


In the Google Maps API v3, the InfoWindow can be attached to an anchor using the open method. Is there any way to retrieve that anchor object?


Solution

  • I don't think this is possible, or at least not convenient, in the current API. The obvious options would be (a) keep track of which InfoWindow goes with which anchor yourself, or (b) call getPosition() on the InfoWindow and find the anchor that returns the same value when getPosition() is called on it. Note that (b) will be problematic if you have multiple anchor/Marker objects in the same location.