问题
I am working on a map where I neet to plot multiple routes using the DirectionService, and each marker on the route has an infoWindow.
Instead of having to keep track of which infoWindow binds to which marker, is there a way for me to grab all infoWindows on a map?
回答1:
There are no way to do what you want.
The map does not know what markers it have or what infowindows those markers have. The Markers know what map they belong to, but that is it. So unfortunatly you will have to keep track of your markers and infowindows if you want to use them after they are created.
回答2:
Why not just have one infowindow, and set the content of it to be different for each marker? Makes life much simpler (unless you ever need to display more than one infowindow open at the same time)
来源:https://stackoverflow.com/questions/7719441/get-all-infowindows-on-a-google-map