React-google-maps: Close InfoWindow?

Created on 9 Mar 2017  路  4Comments  路  Source: tomchentw/react-google-maps

Right now the only way to close an InfoWindow on a MapMarker is by clicking the "X" onCloseClick. Is it possible to close one or all windows when the user clicks elsewhere on the map? Is it possible to close one InfoWindow when the user clicks to open a different InfoWindow so only one is open at any given time?

I feel like adding another property to the InfoWindow (similar to the onRightClick for the Marker component) could handle a function for this or is there already a way to do this that I'm missing? Thanks.

All 4 comments

You can close it by changing state of the marker, change property showInfo to false. Have look at this example: https://tomchentw.github.io/react-google-maps/events/closure-listeners

Ah, so don't make the InfoWindow in charge of closing itself all the time. Put that on the Map itself to listen when users click the overlay or elsewhere and that triggers the close InfoWindow. Thank you!

Please refer to Getting Help section in the README (or #469).

@mjvalade Another way to handle the InfoWindow inside Marker is to have an onMouseOver and onMouseOut event handler that invokes a function or class method handler for toggling. The onMouseOver and onMouseOut would be set on both the Marker and the InfoWindow using function currying and lodash's debounce with a set time. By this you can persist that InfoWindow if the user hovers over it and or until the mouse hovering of a different Marker closing the prior InfoWindow.

The remaining problem is how to disable the "x" which the react-google-maps docs nor source code indicate how to do, and I have a stack overflow question out for:

Maybe @tomchentw could help?

https://stackoverflow.com/questions/51253596/how-to-remove-infowindow-x-react-google-maps

Was this page helpful?
0 / 5 - 0 ratings

Related issues

0x1bitcrack3r picture 0x1bitcrack3r  路  3Comments

MrSaints picture MrSaints  路  3Comments

EvHaus picture EvHaus  路  3Comments

LukasZvikas picture LukasZvikas  路  3Comments

bansalvks picture bansalvks  路  3Comments