您的位置:首页 > 其它

如何使用Core Location获取当前的位置和GPS的坐标呢?

2012-03-26 09:58 477 查看
- (void)locationManager:(CLLocationManager *)manager

didUpdateToLocation:(CLLocation *)newLocation

fromLocation:(CLLocation *)oldLocation

{

if (!gaocoder) {

gaocoder = [[MKReverseGeocoder alloc]initWithCoordinate:newLocation.coordinate];

gaocoder.delegate =self;

[gaocoder start];

}

showmapview.region=MKCoordinateRegionMake(self.bestloaction.coordinate, MKCoordinateSpanMake(0.005f, 0.005f));

showmapview.showsUserLocation=YES;

showmapview.zoomEnabled=NO;

if (!self.bestloaction)self.bestloaction=newLocation;

else if (newLocation.horizontalAccuracy<bestloaction.horizontalAccuracy)

self.bestloaction=newLocation;

latitudeString= [[NSString alloc] initWithFormat:@"%g",newLocation.coordinate.latitude];

NSLog(@"string one:%@",latitudeString);

[latitudeString release];

longitudeString = [[NSString alloc]initWithFormat:@"%g",newLocation.coordinate.longitude];

NSLog(@"string two:%@",longitudeString);

[longitudeString release];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: