我是iphone的新手 通过使用CLLocation我可以找到纬度和经度,但它不适用于在3.2.1中工作的iphonesimulater4.0,请任何人告诉我如何计算纬度和经度在iphone4.0的经度。 提前致谢
答案 0 :(得分:1)
CLLocationCoordinate2D location =
[[[mapview userLocation] location] coordinate];
//NSLog(@"Location found from Map: %f %f",
location.latitude,location.longitude);
答案 1 :(得分:1)
此概念直接在您的应用中删除并检查它是否为纬度和长。
#pragma mark locationManager delegate
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
//if the time interval returned from core location is more than two minutes we ignore it because it might be from an old session
if(abs([newLocation.timestamp timeIntervalSinceDate: [NSDate date]]) < 120)
{
//CLLocation *test = [[CLLocation alloc] initWithLatitude:-33.857034 longitude:151.035929];
currentLocation = newLocation;
coordinates = newLocation.coordinate;
latitude = currentLocation.coordinate.latitude;
longitude = currentLocation.coordinate.longitude;
[locationManager stopUpdatingLocation];
}
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"%@", [error description]);
}
答案 2 :(得分:0)
位置仅显示在真实设备上。您可能会发现CLLocationManager
中的值可以在模拟器中运行(可能来自您的交换机 - 虽然它不会非常准确)但地图上的蓝色引脚将始终位于CA中!