JustFly1984 / react-google-maps-api

React Google Maps API
MIT License
1.79k stars 438 forks source link

Strange behavior of the information window #3350

Open alexkobylansky opened 5 months ago

alexkobylansky commented 5 months ago

163300 171544

Strange behavior of the information window. When I click on the marker, a small empty window appears, which should not be.

AdamZajlerDDH commented 5 months ago

I have the same issue while using it with cluster. It will be nice to see implementaion guide for markers + infowindows + cluster; because i have issue with passing ref from AdvancedMarker to InfoWindow

ggu commented 4 months ago

I wrote some dirty client-side code to deal with this issue:

const handleMarkerClick = useCallback((location) => {
    setActiveMarker(location);
    setTimeout(() => {
      const infoWindowElements = document.querySelectorAll('.gm-style-iw, .gm-style-iw-c');
      infoWindowElements.forEach(element => {
        const children = Array.from(element.children);
        if (children.length === 2 && (!children[0].children.length || !children[1].children.length)) {
          element.parentElement.style.display = 'none';
        }
      });
    }, 50);
  }, []);
nimlevy commented 3 weeks ago

I'm having the same issue. @ggu I'm curious about why did you choose to hide the parent element instead of removing it?

ggu commented 3 weeks ago

I'm having the same issue.

@ggu I'm curious about why did you choose to hide the parent element instead of removing it?

I can't remember, but should be fine to remove.