简体   繁体   中英

Google maps infowindow autopan: is it possible to customize the distance to the map's top?

I have a map with a semi-transparent search bar on top of it. I have also got a bunch of markers with infowindow attached to them.

The problem is that google maps autopan feature obviously doesn't take my search bar into account, therefore if my marker is too close to the top, a part of the infowindow gets covered by the bar.

Is it possible to somehow specify the minimum distance the infowindow needs to be from the map's top?

I was also thinking of limiting the bounds of the map using markers' positions but in my case the markers can also end up under the search bar, so it is not an option.

Any ideas? Thank you for your time!

There exists a library called Snazzy Info Window that can be used instead of the usual InfoWindow. Then you can pass an option edgeOffset in pixels to this object and voila, problem solved. Hope this helps someone in the future!

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