How to get complete address from latitude and longitude?

前端 未结 21 2514
深忆病人
深忆病人 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:46

    Try to use below code using geocoder:

      Geocoder gcd = new Geocoder(MainActivity.this, Locale.getDefault());
      List
    geoAddresses = geoAddresses = gcd.getFromLocation(location.getLatitude(), location.getLongitude(), 1); if (geoAddresses.size() > 0) { String mUserLocation = ""; for (int i = 0; i < 4; i++) { //Since it return only four value we declare this as static. mUserLocation = mUserLocation + geoAddresses.get(0).getAddressLine(i).replace(",", "") + ", "; } }

提交回复
热议问题