我创建了一个类似 uber 的应用程序,但问题是 Pickloaction 显示所有地方,但我的任务是位置只显示德里地方,那么如何处理这个问题?如何使用谷歌地图 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);
嗨,您可以在 PlaceAutocomplete 意图中的“AutocompleteFilter.TYPE_FILTER_CITIES”和 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.
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句