从 LatLng 获取地址

Get address from LatLng

现在我正在使用以下方法在我的 Android Studio MapsActivity 标记中显示 Latitude/Longitude:

 LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(latLng);
    markerOptions.title(String.valueOf(latLng));
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));

    currentLocationMarker = mMap.addMarker((markerOptions));

    mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));

我的目标是显示整个地址。

使用地理编码器从 latlng 获取地址

Geocoder geocoder; 
List<Address> addresses; 
geocoder = new Geocoder(this, Locale.getDefault()); 
addresses = geocoder.getFromLocation(latitude, longitude, 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5 
String address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
String city = addresses.get(0).getLocality();