ios - longitude and latitude values are both 0.000000 , why? -
i use core location longitude , latitude value of current position , have displayed label, case it's 0.000000 both longitude , latitude, because work on simulator ??
//longitude , latitude // locationmanager update location locationmanager = [[cllocationmanager alloc] init]; locationmanager.delegate = self; locationmanager.desiredaccuracy = kcllocationaccuracybest; locationmanager.distancefilter = kcldistancefilternone; [locationmanager startupdatinglocation]; cllocation *location = [locationmanager location]; // configure new event information location cllocationcoordinate2d coordinate = [location coordinate]; nsstring *latitude = [nsstring stringwithformat:@"%f", coordinate.latitude]; nsstring *longitude = [nsstring stringwithformat:@"%f", coordinate.longitude];
just initialization location manager doesn't fetch values.
you have write this
[self.locationmanager startupdatinglocation];
then have override callback method
- (void) locationmanager:(cllocationmanager *)manager didupdatetolocation:(cllocation *) newlocation fromlocation: (cllocation *) oldlocation { [self.locationmanager stopupdatinglocation]; nsstring *latitude = [nsstring stringwithformat:@"%f", newlocation.latitude]; nsstring *longitude = [nsstring stringwithformat:@"%f", newlocation.longitude]; [self.locationmanager release]; }
hope helps!
- shuanak
Comments
Post a Comment