Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
feat(stories): add GeoSearch with InfoWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
samouss committed Jun 19, 2018
1 parent c78f987 commit f6c5271
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions stories/GeoSearch.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,62 @@ stories
}
);

stories.addWithJSX('with InfoWindow', () => {
class Example extends Component {
static propTypes = {
google: PropTypes.object.isRequired,
};

InfoWindow = new this.props.google.maps.InfoWindow();

onClickMarker = ({ hit, marker }) => {
if (this.InfoWindow.getMap()) {
this.InfoWindow.close();
}

this.InfoWindow.setContent(hit.name);

this.InfoWindow.open(marker.getMap(), marker);
};

renderGeoHit = hit => (
<Marker
key={hit.objectID}
hit={hit}
anchor={{ x: 0, y: 5 }}
onClick={({ marker }) => {
this.onClickMarker({
hit,
marker,
});
}}
/>
);

render() {
const { google } = this.props;

return (
<WrapWithHits indexName="airbnb" linkedStoryGroup="GeoSearch">
<Configure aroundLatLngViaIP hitsPerPage={20} />

<Container>
<GeoSearch google={google}>
{({ hits }) => <Fragment>{hits.map(this.renderGeoHit)}</Fragment>}
</GeoSearch>
</Container>
</WrapWithHits>
);
}
}

return (
<GoogleMapsLoader apiKey={apiKey}>
{google => <Example google={google} />}
</GoogleMapsLoader>
);
});

stories.addWithJSX('with hits communication (custom)', () => {
const CustomHits = connectHits(({ hits, selectedHit, onHitOver }) => (
<div className="hits">
Expand Down

0 comments on commit f6c5271

Please sign in to comment.