google-map-react icon indicating copy to clipboard operation
google-map-react copied to clipboard

Safari onChange bounds and size invalid values

Open juanmahidalgo opened this issue 5 years ago • 2 comments

Hi there! Some weird stuff is going on Safari. Not quite sure the reason but seems like a condition race is taking place somewhere.

Describe the bug 🐛

First onChange triggered once the map is loaded is returning invalid bounds and size values on the event object on Safari. It's working perfectly in Chrome.

To Reproduce 🔍

Steps to reproduce the behavior:

  1. Mount the component
  2. Debug event on the onChange callback once the map is loaded
  3. Observe values

Expected behavior 💭

On chrome the event it's returning correct values for the initial center passed in the props.

image

Screenshots 🖥

On Safari, seems like there is a condition race. Most of the time, the event comes with incorrect values. Sometimes, the value are correct. image

Environment:

  • OS: OSX
  • Browser: Safari
  • Version: latest

Additional context

Code fragment of how Component is being called:

<GoogleMapReact
        bootstrapURLKeys={{
          key: window.GOOGLE_MAPS_CONFIG.apiKey,
          libraries: 'places',
        }}
        defaultCenter={MAP_INITIAL_POSITION}
        center={getInitialPosition()}
        defaultZoom={getInitialZoom()}
        onDrag={handleSetOnDrag}
        onDragEnd={onDragEnd}
        onZoomAnimationEnd={handleOnZoomEnd}
        yesIWantToUseGoogleMapApiInternals
        onGoogleApiLoaded={onGoogleApiLoaded}
        onChange={handleChange}
        options={{
          fullscreenControl: false,
          zoomControl: false,
          styles: MAP_STYLES,
        }}
      >
        {markers}
      </GoogleMapReact>

Any ideas of what's going on? When I get a chance, I could have a look at the implementation, try to find the issue and send the PR for it.

juanmahidalgo avatar May 11 '20 15:05 juanmahidalgo

It's interesting because I have the same problem with Chrome and I have all the correct values with Firefox.

Linkinou avatar Aug 13 '20 14:08 Linkinou

I get this in capacitor as well. Doesn't always happen, seems pretty random whenever map first loads

zmays avatar Jun 13 '23 18:06 zmays