React native Google自动放置提供位置建议的速度非常慢
我正在制作一个react-native应用程序,它需要react-native中的GooglePlacesSuggestion。所以我用了一个包:React native Google自动放置提供位置建议的速度非常慢,react-native,React Native,我正在制作一个react-native应用程序,它需要react-native中的GooglePlacesSuggestion。所以我用了一个包: react原生google places自动完成 代码如下: <View style = {{margin:10,padding:20,flex:1}}> <GooglePlacesAutocomplete placeholder='Search' minLen
react原生google places自动完成
代码如下:
<View style = {{margin:10,padding:20,flex:1}}>
<GooglePlacesAutocomplete
placeholder='Search'
minLength={2} // minimum length of text to search
autoFocus={false}
returnKeyType={'search'} // Can be left out for default return key https://facebook.github.io/react-native/docs/textinput.html#returnkeytype
listViewDisplayed='auto' // true/false/undefined
fetchDetails={true}
renderDescription={row => row.description} // custom description render
onPress={(data, details = null) => { // 'details' is provided when fetchDetails = true
// ToastAndroid.show(JSON.stringify(data),ToastAndroid.LONG)
let city = details.address_components[0].long_name
let lat = details.geometry.location.lat
let lng = details.geometry.location.lng
let full_addr= details.formatted_address
}}
getDefaultValue={() => ''}
query={{
key: 'AIzaSyB-q60XaNf5nsz5678e1jaRg0KTs5Q1nPi2Zk',
language: 'en', // language of the results
types: 'geocode' // default: 'geocode'
}}
styles={{
textInputContainer: {
width: '100%'
},
description: {
fontWeight: 'bold'
}
}}
nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
GoogleReverseGeocodingQuery={{
}}
GooglePlacesSearchQuery={{
rankby: 'distance',
types: 'food'
}}
filterReverseGeocodingByTypes={[ 'political','administrative_area_level_3']} // filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities
debounce={200} // debounce the requests in ms. Set to 0 to remove debounce. By default 0ms.
/>
</View>
row.description}//自定义描述呈现
onPress={(data,details=null)=>{//'details'在fetchDetails=true时提供
//show(JSON.stringify(数据),ToastAndroid.LONG)
let city=details.address\u components[0]。long\u name
设lat=details.geometry.location.lat
let lng=细节。几何。位置。lng
让full\u addr=details.formatted\u地址
}}
getDefaultValue={()=>''}
质疑={{
关键字:“AIzaSyB-q60XaNf5nsz5678e1jaRg0KTs5Q1nPi2Zk”,
语言:“en”,//结果的语言
类型:“地理编码”//默认值:“地理编码”
}}
风格={{
textInputContainer:{
宽度:“100%”
},
说明:{
fontWeight:“粗体”
}
}}
nearbyPlacesAPI='GooglePlacesSearch'//使用哪种API:GoogleReverseGeoCode或GooglePlacesSearch
谷歌反向分类查询={{
}}
GooglePlacesSearchQuery={{
兰比:“距离”,
类型:“食物”
}}
filterReverseGeocodingByTypes={['political','administrative_area_level_3']}//如果只想显示城市,请按类型['locality','administrative_area_level_3']过滤反向地理编码结果
debounce={200}//debounce以毫秒为单位的请求。设置为0可删除debounce。默认情况下为0毫秒。
/>
但是上面的代码有两个问题。在键入任何位置时,我得到的响应非常慢,我的意思是,在键入位置的字符或单词后,显示结果需要2-3秒,有时它不显示任何结果。为什么?另外,如果我想根据道路名称和区域名称搜索地址,那么它不会给我任何建议。为什么?我被这两个问题困住了,请在这两个问题上帮助我。提前谢谢