public static LocationModel getLocationByCoordinates ( Double latitude , Double longitude ) { try { Geocoder geocoder ; List < Address > addresses ; geocoder = new Geocoder ( QuickUtils . getContext ( ) ) ; addresses = geocoder . getFromLocation ( latitude , longitude , 1 ) ; LocationModel locationModel = new LocationModel ( ) ; locationModel . latitude = latitude ; locationModel . longitude = longitude ; try { locationModel . address = addresses . get ( 0 ) . getAddressLine ( 0 ) ; } catch ( Exception ex ) { QuickUtils . log . e ( "empty address" ) ; } try { locationModel . city = addresses . get ( 0 ) . getAddressLine ( 1 ) ; } catch ( Exception ex ) { QuickUtils . log . e ( "empty city" ) ; } try { locationModel . country = addresses . get ( 0 ) . getAddressLine ( 2 ) ; } catch ( Exception ex ) { QuickUtils . log . e ( "empty country" ) ; } return locationModel ; } catch ( IOException e ) { QuickUtils . log . e ( "empty location" ) ; return new LocationModel ( ) ; } }
Gets the location by Coordinates