import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { LatLngPropType, BoundingBoxPropType } from './propTypes'; import Connector from './Connector'; import Provider from './Provider'; import GoogleMaps from './GoogleMaps'; class GeoSearch extends Component { static propTypes = { google: PropTypes.object.isRequired, children: PropTypes.func.isRequired, initialZoom: PropTypes.number, initialPosition: LatLngPropType, enableRefine: PropTypes.bool, enableRefineOnMapMove: PropTypes.bool, defaultRefinement: BoundingBoxPropType, }; static defaultProps = { initialZoom: 1, initialPosition: { lat: 0, lng: 0 }, enableRefine: true, enableRefineOnMapMove: true, defaultRefinement: null, }; renderChildrenWithBoundFunction = ({ hits, position, ...rest }) => { const { google, children, initialZoom, initialPosition, enableRefine, enableRefineOnMapMove, defaultRefinement, ...mapOptions } = this.props; return ( {({ boundingBox, boundingBoxPadding, onChange, onIdle, shouldUpdate, }) => ( {children({ hits })} )} ); }; render() { const { enableRefineOnMapMove, defaultRefinement } = this.props; return ( {this.renderChildrenWithBoundFunction} ); } } export default GeoSearch;