无法解析符号 'GeoPoint'
Cannot resolve symbol 'GeoPoint'
不确定发生了什么,但是当我尝试调用 GeoPoint 以获取设备当前的经度和纬度时,我收到通知“无法解析符号 'GeoPoint'。不太确定出了什么问题
private void getLastKnownLocation() {
Log.d(TAG, "getLastKnownLocation: called.");
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mFusedLocationClient.getLastLocation().addOnCompleteListener(new OnCompleteListener<android.location.Location>() {
@Override
public void onComplete(@NonNull Task<android.location.Location> task) {
if (task.isSuccessful()) {
Location location = task.getResult();
GeoPoint geoPoint = new GeoPoint(location.getLatitude(), location.getLongitude());
Log.d(TAG, "onComplete: latitude: " + geoPoint.getLatitude());
Log.d(TAG, "onComplete: longitude: " + geoPoint.getLongitude());
}
}
});
}
尝试使用 LatLng 而不是 GeoPoint:
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
不确定发生了什么,但是当我尝试调用 GeoPoint 以获取设备当前的经度和纬度时,我收到通知“无法解析符号 'GeoPoint'。不太确定出了什么问题
private void getLastKnownLocation() {
Log.d(TAG, "getLastKnownLocation: called.");
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mFusedLocationClient.getLastLocation().addOnCompleteListener(new OnCompleteListener<android.location.Location>() {
@Override
public void onComplete(@NonNull Task<android.location.Location> task) {
if (task.isSuccessful()) {
Location location = task.getResult();
GeoPoint geoPoint = new GeoPoint(location.getLatitude(), location.getLongitude());
Log.d(TAG, "onComplete: latitude: " + geoPoint.getLatitude());
Log.d(TAG, "onComplete: longitude: " + geoPoint.getLongitude());
}
}
});
}
尝试使用 LatLng 而不是 GeoPoint:
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());