我希望将Google地方信息搜索结果限制在用户当前位置周围20英里。
将radius参数添加到查询中根本不起作用。这是我的代码:
query={{
// available options: https://developers.google.com/places/web-service/autocomplete
key: 'AIzaSyCMFiyTGVGJQgi1AOShIuRppi9JqcSgobw',
language: 'en', // language of the results
types: ['street_address', 'establishment'], // default: 'geocode'
components: 'country:us'
latitude: 32.795969,
longitude: -80.028863,
radius: 100
}}
styles={locationAutocompleteStyle}
currentLocation={false} // Will add a 'Current location' button at the top of the predefined places list
currentLocationLabel="Current location"
nearbyPlacesAPI="GooglePlacesSearch" // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
GoogleReverseGeocodingQuery={{
// available options for GoogleReverseGeocoding API : https://developers.google.com/maps/documentation/geocoding/intro
}}
GooglePlacesSearchQuery={{
// available options for GooglePlacesSearch API : https://developers.google.com/places/web-service/search
// rankby: 'distance',
}}
答案 0 :(得分:0)
您提供的半径以米为单位,它应该是一个字符串
你可以试试这个
<GooglePlacesAutocomplete
placeholder='search'
minLength={2}
autoFocus={true}
returnKeyType={'default'}
fetchDetails={true}
query={{
key: '***********8',
language: 'es', // language of the results
location: '20.8840744, -100.7607736',
radius: '15000', //15 km
components:'country:mx',
strictbounds: true,
}}
/>