Android Google放置自动完成反应本地自定义视图
我正在开发一个react原生应用程序,它使用react原生google places autocomplete。我想自定义它的列表视图,这样它就可以像模型一样覆盖所有其他组件。目前,当我们搜索一个位置时,列表视图位于其他组件下。下面是我的代码,如何让它成为所有其他组件的首选Android Google放置自动完成反应本地自定义视图,android,react-native,listview,googleplacesautocomplete,Android,React Native,Listview,Googleplacesautocomplete,我正在开发一个react原生应用程序,它使用react原生google places autocomplete。我想自定义它的列表视图,这样它就可以像模型一样覆盖所有其他组件。目前,当我们搜索一个位置时,列表视图位于其他组件下。下面是我的代码,如何让它成为所有其他组件的首选 <GooglePlacesAutocomplete placeholder='Search' minLength={2} // minimum length of text to
<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='false' // true/false/undefined
fetchDetails={true}
renderDescription={row => row.description} // custom description render
onPress={(data, details = null) => { // 'details' is provided when fetchDetails = true
console.log(data, details);
this.setState({latitutde:details.geometry.location.lat})
this.setState({longitude:details.geometry.location.lng})
}}
getDefaultValue={() => ''}
query={{
// available options: https://developers.google.com/places/web-service/autocomplete
key: 'AIzaSyBVFryoOZQmqeiTmqDoO1r1V8E-2NIlAqk',
language: 'en', // language of the results
types: '(cities)' // default: 'geocode'
}}
styles={{
listView: {
backgroundColor: 'white',
borderRadius: 5,
flex: 1,
elevation: 3,
zIndex: 10
},
textInputContainer: {
borderTopWidth: 0,
borderBottomWidth:0,
width: '90%',
backgroundColor: 'transparent',
},
}}
//currentLocation={true} // 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',
types: 'food'
}}
filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} // filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities
//predefinedPlaces={[homePlace, workPlace]}
debounce={200} // debounce the requests in ms. Set to 0 to remove debounce. By default 0ms.
/>
row.description}//自定义描述呈现
onPress={(data,details=null)=>{//'details'在fetchDetails=true时提供
控制台日志(数据、详细信息);
this.setState({latitude:details.geometry.location.lat})
this.setState({经度:details.geometry.location.lng})
}}
getDefaultValue={()=>''}
质疑={{
//可用选项:https://developers.google.com/places/web-service/autocomplete
关键字:“AIZASYBVFRYOOZQMQEITMQODOO1R1V8E-2NIlAqk”,
语言:“en”,//结果的语言
类型:'(城市)//default:'geocode'
}}
风格={{
列表视图:{
背景颜色:“白色”,
边界半径:5,
弹性:1,
标高:3,
zIndex:10
},
textInputContainer:{
borderTopWidth:0,
边框底部宽度:0,
宽度:“90%”,
背景色:“透明”,
},
}}
//currentLocation={true}//将在预定义位置列表的顶部添加一个“Current location”按钮
//currentLocationLabel=“当前位置”
nearbyPlacesAPI='GooglePlacesSearch'//使用哪种API:GoogleReverseGeoCode或GooglePlacesSearch
谷歌反向分类查询={{
//谷歌反向编码API的可用选项:https://developers.google.com/maps/documentation/geocoding/intro
}}
GooglePlacesSearchQuery={{
//Google PlacesSearch API的可用选项:https://developers.google.com/places/web-service/search
兰比:“距离”,
类型:“食物”
}}
filterReverseGeocodingByTypes={['Location','administrative_area_level_3']}//如果只想显示城市,请按类型['Location','administrative_area_level_3']过滤反向地理编码结果
//预定义地点={[homePlace,workPlace]}
debounce={200}//debounce以毫秒为单位的请求。设置为0可删除debounce。默认情况下为0毫秒。
/>
我在处理此类问题时发现的唯一解决方案是,将代码包装在容器中,根据需要增加容器的高度,然后将容器背景色设置为透明。另一个解决方案是有条件地将主容器的高度设置为列表视图的高度。我在处理此类问题时找到的唯一解决方案是,将代码包装在容器中,并根据需要增加容器的高度,然后将容器背景色设置为透明。另一个解决方案是有条件地将主容器的高度设置为列表视图的高度