How to get complete address from latitude and longitude?

前端 未结 21 2497
深忆病人
深忆病人 2020-11-22 09:07

I want to get following values from Latitude and Longitude in android

  1. Street Address
  2. City / State
  3. Zip
  4. Complete Address
<
21条回答
  •  青春惊慌失措
    2020-11-22 09:38

      public static String getAddressFromLatLng(Context context, LatLng latLng) {
        Geocoder geocoder;
        List
    addresses; geocoder = new Geocoder(context, Locale.getDefault()); try { addresses = geocoder.getFromLocation(latLng.latitude, latLng.longitude, 1); return addresses.get(0).getAddressLine(0); } catch (Exception e) { e.printStackTrace(); return ""; } }

提交回复
热议问题