我正在使用PlacePicker
来选择用户的当前位置并显示其选择位置。选择当前位置并获取其经度和经度工作正常但通过纬度和地图显示已在地图上选择的位置经度不工作显示当前位置而不是选择location.Here是我的代码,请帮我解决这个问题。感谢任何帮助。谢谢
private void openGoogleLocationScreen(String longitude,String latitude) {
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
if (!TextUtils.isEmpty(longitude) && !TextUtils.isEmpty(latitude)) {
LatLng llg = new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude));
builder.setLatLngBounds(getLocationBounds(llg, 5500));
}
try {
startActivityForResult(builder.build(getActivity()), PLACE_PICKER_REQUEST);
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
}
// To get LocationBounds of given Latitude and Longitude.
private LatLngBounds getLocationBounds(LatLng location, int mDistanceInMeters) {
double latRadian = Math.toRadians(location.latitude);
double degLatKm = 110.574235;
double degLongKm = 110.572833 * Math.cos(latRadian);
double deltaLat = mDistanceInMeters / 1000.0 / degLatKm;
double deltaLong = mDistanceInMeters / 1000.0 / degLongKm;
double minLat = location.latitude - deltaLat;
double minLong = location.longitude - deltaLong;
double maxLat = location.latitude + deltaLat;
double maxLong = location.longitude + deltaLong;
return new LatLngBounds(new LatLng(minLat, minLong), new LatLng(maxLat, maxLong));
}