如何解决自动完成搜索栏Google地图无法加载结果
在我遵循的教程中,我在应用程序中创建了Google地图的自动填充搜索栏,只有这样的代码
XML
<fragment
android:id="@+id/place_autocomplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
片段
private var mMap: GoogleMap? = null
internal var placeAutoComplete: PlaceAutocompleteFragment? = null
placeAutoComplete = activity!!.fragmentManager.findFragmentById(R.id.place_autocomplete) as PlaceAutocompleteFragment
placeAutoComplete!!.setOnPlaceSelectedListener(object : PlaceSelectionListener {
override fun onPlaceSelected(place: Place) {
Log.d("Maps","Place selected: " + place.getName())
}
override fun onError(status: Status) {
Log.d("Maps","An error occurred: $status")
}
})
val mapFragment = childFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
mapFragment!!.getMapAsync(this)
Gradle
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-places:16.0.0'
但是当我在搜索栏上搜索时,结果无法加载结果。有人知道如何解决这个问题吗?我已经尝试搜索解决方案,但没有一个能解决我的问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。