ios - Not getting a correct address from Latitude & Longitude -


i want true postal address latitude & longitude, not working well. maybe note using right apis or etc.

example have following code

           var location = cllocation(latitude:currentlocation.coordinate.latitude, longitude: currentlocation.coordinate.longitude)          clgeocoder().reversegeocodelocation(location, completionhandler: {(placemarks, error) -> void in         print(location)              if error != nil {                 print("reverse geocoder failed error" + error!.localizeddescription)                 return             }             if placemarks!.count > 0 {                 let pm = placemarks![0] as! clplacemark                 street = string(pm.thoroughfare!)                 city = string(pm.locality!)                 state = string(pm.administrativearea!)                 print(pm.locality)                 print(pm.administrativearea)                 print(pm.thoroughfare)                 self.utility.setmylocation(dname, longitude: long, latitude: lat, street: street, city: city, state: state)                 locmanager.stopupdatinglocation()              }             else {                 print("problem data received geocoder")             }         }) 

however not getting true address. example let if long , lat address

123 east street

east street (with no number) or near road.

need inorder real address?

im not sure if looking use nice readable address. send these values application delegate referencing later if need them. don't have written in swift in objective c. :/ think key reversegeocodelocation

#pragma mark - location manager update , functions - (void)locationmanager:(cllocationmanager *)manager didfailwitherror:(nserror *)error{     nslog(@"%s failed error: %@", __pretty_function__, error); }  - (void)locationmanager:(cllocationmanager *)manager didupdatetolocation:(cllocation *)newlocation fromlocation:(cllocation *)oldlocation {      nslog(@"%s update location: %@", __pretty_function__, newlocation);     appdelegate *appdelegate = [[uiapplication sharedapplication] delegate];     cllocation *currentlocation = newlocation;      if (currentlocation != nil) {         nsstring *longitude = [nsstring stringwithformat:@"%.8f", currentlocation.coordinate.longitude];         nsstring *latitude = [nsstring stringwithformat:@"%.8f", currentlocation.coordinate.latitude];         nslog(@"longitude: %@", longitude);         nslog(@"latitude: %@", latitude);          // set current values appdelegate refrencing         appdelegate.locationdetaillon = longitude;         appdelegate.locationdetaillat = latitude;     }      // stop location manager save power     [locationmanager stopupdatinglocation];      // reverse geocoding     nslog(@"translating , getting address");     [geocoder reversegeocodelocation:currentlocation completionhandler:^(nsarray *placemarks, nserror *error) {         //        nslog(@"found placemarks: %@, error: %@", placemarks, error);         if (error == nil && [placemarks count] > 0) {             placemark = [placemarks lastobject];             nsstring *address = [nsstring stringwithformat:@"%@ %@\n%@ %@\n%@\n%@",                                  placemark.subthoroughfare, placemark.thoroughfare,                                  placemark.postalcode, placemark.locality,                                  placemark.administrativearea,                                  placemark.country];             nslog(@"address:\n%@", address);              // set current values appdelegate refrencing             appdelegate.locationdetailstate = placemark.administrativearea;             appdelegate.locationdetailcountry = placemark.country;             appdelegate.locationdetailcity = placemark.locality;             appdelegate.locationdetailpostcode = placemark.postalcode;           } else {             nslog(@"%s error: %@", __pretty_function__, error.debugdescription);         }     } ]; } 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -