UNPKG

@syncromatics/react-google-maps

Version:
47 lines (43 loc) 1.08 kB
### Click the Marker to show InfoWindow ```jsx const { compose, withProps, withStateHandlers } = require("recompose"); const FaAnchor = require("react-icons/lib/fa/anchor"); const { withScriptjs, withGoogleMap, GoogleMap, Marker, InfoWindow, } = require("@syncromatics/react-google-maps"); const MapWithAMakredInfoWindow = compose( withStateHandlers(() => ({ isOpen: false, }), { onToggleOpen: ({ isOpen }) => () => ({ isOpen: !isOpen, }) }), withScriptjs, withGoogleMap )(props => <GoogleMap defaultZoom={8} defaultCenter={{ lat: -34.397, lng: 150.644 }} > <Marker position={{ lat: -34.397, lng: 150.644 }} onClick={props.onToggleOpen} > {props.isOpen && <InfoWindow onCloseClick={props.onToggleOpen}> <FaAnchor /> </InfoWindow>} </Marker> </GoogleMap> ); <MapWithAMakredInfoWindow googleMapURL={GOOGLE_MAP_URL} loadingElement={<div style={{ height: `100%` }} />} containerElement={<div style={{ height: `400px` }} />} mapElement={<div style={{ height: `100%` }} />} /> ```