Get latitude and longitude based on city, zip or streetname

后端 未结 4 2162
悲&欢浪女
悲&欢浪女 2020-12-30 17:12

In my current android application, I would like to get the geocordinates based on an entered city name, street name or zip code. How can I accomplish this?

Best Rega

4条回答
  •  梦谈多话
    2020-12-30 17:48

    Try this.

    Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault());
    try {
        List
    addresses = geoCoder.getFromLocation(latitude , longitude, 1); String strCompleteAddress= ""; //if (addresses.size() > 0) //{ for (int i=0; i ", strCompleteAddress); Toast.makeText(getBaseContext(), strCompleteAddress, Toast.LENGTH_LONG).show(); } catch (IOException e) { Log.i("MyLocTAG => ", "this is the exception part"); e.printStackTrace(); }

提交回复
热议问题