目前我正在使用以下内容在Android Studio MapsActivity Marker中显示纬度/经度:
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));
我的目标是显示整个地址。
答案 0 :(得分:0)
使用地理编码器从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();