简体   繁体   中英

Click to focus on InfoWindow on Google Maps API v3

Much like any OS where if you click on a window then it brings that window in focus (on top). Is that also possible if you have two overlapping InfoWindow for Google Maps API v3?

I know that there is no click listener for InfoWindow class as shown in the official Google Maps API v3 reference . But there is a content_changed listener.

So currently I am thinking of a "hack" would be something like this:

  1. The content div is clicked (a listener via JavaScript of jQuery)
  2. The content div will be changed subtly (add an extra invisible character at the end or something)
  3. Update the content by InfoWindow.setContent()
  4. The content_changed listener will trigger
  5. Set a higher z-index by InfoWindow.setZIndex()

Is there a better way to do this?

If you are going to do this... i hope you dont have to many info windows!

But would it not just be simpler to generate an array of all you info windows, then when you div is clicked move that ones z-index higher and the others all lower. Then you just need to have the object name of the info window to call myInfoWindow.setZIndex().

A little simpler.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM