We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Two infowindows appear after clicking a marker, the weird thing is sometimes in inspection mode infowindow appear normally.
import { DirectionsRenderer,GoogleMap, Marker,withGoogleMap,withScriptjs, InfoWindow } from "react-google-maps"; import PlacesAutocomplete,{ geocodeByAddress, getLatLng } from 'react-places-autocomplete'; import { nanoid } from 'nanoid' import React, { Component } from 'react' const API_KEY = 'AIzaSyCItFAnykxtWLwWWcg4-WPlto-SwSFWui8' const MyMapComponent = withScriptjs(withGoogleMap((props) => <GoogleMap defaultZoom={8} defaultCenter={{ lat: -33.897, lng: 151.144 }} > {props.locs.map((location)=>{ const onMarkerClick = props.onMarkerClick.bind(this,location) return <Marker key={nanoid()} position={location} onClick={onMarkerClick}> </Marker> })} {props.showingInfoWindow && <InfoWindow position={props.activeMarker} onCloseClick={props.markerInfoClose}> <h1>Details</h1> </InfoWindow>} </GoogleMap> )); export default class Test extends Component { constructor(props) { super(props); this.state = { locations:[{lat: -33.865143,lng: 151.2}, {lat: -33.865143,lng: 151},], showingInfoWindow: false, activeMarker: {}, }; } onMarkerClick = (location) =>{ this.setState({ activeMarker: location, showingInfoWindow: true }); } onClose = () => { if (this.state.showingInfoWindow) { this.setState({ activeMarker: null, showingInfoWindow: false }); } }; render() { console.log(this.state.activeMarker) return ( <div> <MyMapComponent locs={this.state.locations} onMarkerClick={this.onMarkerClick} showingInfoWindow={this.state.showingInfoWindow} activeMarker={this.state.activeMarker} markerInfoClose={this.onClose} containerElement={ <div style={{ height: `1000px`, width: '1000px' }} /> } mapElement={ <div style={{ height: `100%` }} /> } loadingElement={<div style={{ height: `100%` }} />} googleMapURL={`https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places&key=${API_KEY}`} > </MyMapComponent> </div> ) } }
The text was updated successfully, but these errors were encountered:
Here's the screenshoot of two infowindows on one marker
Sorry, something went wrong.
As far as I understand, this is due to strict mode
it is because of the strict mode. thanks for the comment @zharikovartem
const nextConfig = { reactStrictMode: true, //set to false };
No branches or pull requests
Two infowindows appear after clicking a marker, the weird thing is sometimes in inspection mode infowindow appear normally.
The text was updated successfully, but these errors were encountered: