ios - getting different location even if I am not moving -


i using below code getting longitude , latitude , gives me diifferent values if not moving place

 locationmanager=[[cllocationmanager alloc]init];     geocoder=[[clgeocoder alloc]init];      locationmanager.delegate=self;     locationmanager.desiredaccuracy=kcllocationaccuracybest;     if([[[uidevice currentdevice] systemversion] floatvalue] >= 8.0)     {         [locationmanager requestwheninuseauthorization];     }     [locationmanager startupdatinglocation];        -(void)locationmanager:(cllocationmanager *)manager didfailwitherror:(nserror *)error     {         uialertview *alert=[[uialertview alloc]initwithtitle:@"error" message:@"failed location." delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil, nil];         [alert show];     }      -(void)locationmanager:(cllocationmanager *)manager didupdatetolocation:(cllocation *)newlocation fromlocation:(cllocation *)oldlocation     {         cllocation *currentlocation=newlocation;      if (currentlocation!=nil)     {          longitude=currentlocation.coordinate.longitude;         latitude=currentlocation.coordinate.latitude;      }          [geocoder reversegeocodelocation:currentlocation completionhandler:^(nsarray *placemarks, nserror *error) {            } ];      } 

please guide me, want same location, if not moving place.

cellular network location gives approximate area phone existing. based on service providers tower.so current location automatically changes bit depending on network/gps location tracking/accuracy.

i recommend location using distance filter, until in region current address remain same location updates every x meters.

locationmanager.distancefilter = 100;//your own distance 

i.e.,

self.locationmanager = [[[cllocationmanager alloc] init] autorelease];     _locationmanager.delegate = self;     // important property set manager. determines how manager     // attempt acquire location , thus, amount of power consumed.     _locationmanager.distancefilter = 100;     // once configured, location manager must "started".     [_locationmanager startupdatinglocation]; 

hope helps.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -