问题描述
我正在获取用户的当前位置,当我第一次单击它时显示不同的位置(即距当前位置超过10公里) 而且,如果我再次单击该按钮,它将显示确切的当前位置
注意:问题发生在三星M系列和A系列-Android版本10
解决方法
在我的情况下,我解决了这样的问题,
在我这样使用之前
location_gps_image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View vw) {
if (location != null) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();
LatLng cur_Latlng = new LatLng(latitude,longitude);
googleMap.moveCamera(CameraUpdateFactory.newLatLng(cur_Latlng));
googleMap.animateCamera(CameraUpdateFactory.zoomTo(17));
}
});
我不是这样更新的,它对我有用
location_gps_image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View vw) {
if (location != null) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();
LatLng cur_Latlng = new LatLng(latitude,longitude);
CameraUpdate currentLocation = CameraUpdateFactory.newLatLngZoom(cur_Latlng,17);
googleMap.animateCamera(currentLocation);
}
});