I'm using the react-google-maps library and I've been doing pretty well so far. My app receives a json with locations from my backend and I'm mapping them to add Markers on the map, they are displaying just fine. These markers have an OnClick function which sets information on a ReactHook.
When my hook state changes, my InfoWindow triggers and displays itself and this is fine. The problem is a little InfoWindow with no information which triggers at the same time than the other, i have tried to find the error for a few hours now and I can't find it, I've checked the code and also I'be inspect the components from the Browser but that little InfoWindow is not being recognized by the react developer tools.
Here is my code:
function Map(props){
const [selectedTienda, setSelectedTienda] = useState(null)
const options ={
styles: MapStyles,
disableDefaultUI: true,
}
return(
<GoogleMap
defaultZoom={17}
defaultCenter={{lat: 29.0824139, lng: -110.966389}}
options={options}
>
{props.items.map(tienda =>(
<Marker
key={tienda['tienda.id']}
position={{
lat: parseFloat(tienda['tienda.ubicacion.lat']),
lng: parseFloat(tienda['tienda.ubicacion.lng'])
}}
onClick={()=>{
setSelectedTienda(tienda);
}}
/>
))}
{selectedTienda ? (
<InfoWindow position={{
lat: parseFloat(selectedTienda['tienda.ubicacion.lat']),
lng: parseFloat(selectedTienda['tienda.ubicacion.lng'])
}}
onCloseClick={()=>{setSelectedTienda(null)}}
>
<div><h4>This is the <br/>INFOWINDOW I WANT</h4></div>
</InfoWindow>
): null}
</GoogleMap>
)
}
const MyMapComponent = withScriptjs(withGoogleMap(Map))
Here is also an image of my nightmare:
Here is what my react dev tools is showing, which is only the main InfoWindow