gpt4 book ai didi

java - 如何在自动完成地点谷歌地图API中创建边界(仅特定地点)

转载 作者:行者123 更新时间:2023-12-02 06:04:54 26 4
gpt4 key购买 nike

我创建了一个像Uber一样的应用程序,但问题是pickuploaction显示了所有地点,但我的任务是位置仅显示德里地点,那么如何处理这个问题?如何使用谷歌地图API仅显示德里地点???请有人解决这个问题吗?

private void moveCamera(LatLng latLng, float zoom, PlaceInfo placeInfo){
Log.d(TAG, "moveCamera: moving the camera to: lat: " + latLng.latitude + ", lng: " + latLng.longitude );
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoom));

mMap.clear();
try {
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.setCountry("au")
.build();
Intent intent = new PlaceAutocomplete.IntentBuilder
(PlaceAutocomplete.MODE_FULLSCREEN)
.setFilter(typeFilter)
.build(PickUp_Location.this);
startActivityForResult(intent, REQUEST_SELECT_PLACE);
} catch (GooglePlayServicesRepairableException |
GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter(PickUp_Location.this));

if(placeInfo != null){
try{
String snippet = "Address: " + placeInfo.getAddress() + "\n" +
"Phone Number: " + placeInfo.getPhoneNumber() + "\n" +
"Website: " + placeInfo.getWebsiteUri() + "\n" +
"Price Rating: " + placeInfo.getRating() + "\n";

MarkerOptions options = new MarkerOptions()
.position(latLng)
.title(placeInfo.getName())
.snippet(snippet);

最佳答案

您好,您可以在“AutocompleteFilter.TYPE_FILTER_CITIES”和 PlaceAutocomplete Intent 中的 setBoundsBias 的帮助下尝试如下操作:

您可以根据您所在的城市区域更改 lat lng 边界(我已添加印度德里的 lat lng 边界)

try {
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES)
.build();

Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
.setFilter(typeFilter)
.setBoundsBias(new LatLngBounds(new LatLng(28.7041, 77.1025), new LatLng(28.7041, 77.1025)))
.build(TestatorDetailsActivity.this);
startActivityForResult(intent, DEFAULT_KEYS_SEARCH_GLOBAL);
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
// TODO: Handle the error.
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
// TODO: Handle the error.
}

关于java - 如何在自动完成地点谷歌地图API中创建边界(仅特定地点),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55947014/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com