Google Maps API: Disable scroll into view on map focus?

50 Views Asked by At

I have an embeded Google Map which extends vertically below the viewport. When the map gains focus (e.g. by clicking), my browser viewport scrolls to reveal as much of the map as possible.

This is clearly standard Google Maps API behaviour. You can reproduce it e.g. here by focussing on a map that is only partially visible in the viewport: https://developers.google.com/maps/documentation/embed/quickstart

I would like to disable this behaviour, as I find it to be disorienting. Is this possible?

The Google Maps API does not seem to expose an onFocus event for the map itself. Only a pretty customized onClick event, but I wouldn't know how to stop the page scroll with that. (https://developers.google.com/maps/documentation/javascript/events)

FWIW I am using React and vis.gl's react-google-maps library. Since React's own onFocus event bubbles, I could catch it further up the DOM, but again I don't know how to stop it from triggering the scroll.

Thank you for any ideas!

1

There are 1 best solutions below

0
gl03 On

Described behaviour was a bug and is fixed as of Feb 16, 2024.

Google issue tracker ticket: https://issuetracker.google.com/issues/321195512?pli=1