如何使用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];
}
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];
}
相关文章推荐
- Android 成功 使用GPS获取当前地理位置(解决getLastKnownLocation 返回 null)
- iOS GPS定位CLLocationManager获取当前位置坐标 示例代码
- HTML5 调用 GPSAPI 获取当前位置的坐标 显示在地图上(有包括百度地图与谷歌地图)
- Android 成功 使用GPS获取当前地理位置(解决getLastKnownLocation 返回 null)
- Android 成功 使用GPS获取当前地理位置(解决getLastKnownLocation 返回 null)
- Android 成功 使用GPS获取当前地理位置(解决getLastKnownLocation 返回 null)
- Android 使用GPS获取当前地理位置
- Android 成功 使用GPS获取当前地理位置(解决getLastKnownLocation 返回 null)
- Android 成功 使用GPS获取当前地理位置(解决getLastKnownLocation)
- Android 成功 使用GPS获取当前地理位置(解决getLastKnownLocation 返回 null)
- 如何获取当前GPS坐标附近最近的地点名称?
- Android 成功 使用GPS获取当前地理位置(解决getLastKnownLocation 返回 null)
- WinRT获取坐标和当前的位置
- 使用定位获取当前位置信息
- [原创]Android中LocationManager的简单使用,获取当前位置
- 如何获取当前使用的Locale信息
- 调用Android位置服务获取当前坐标
- Android中通过GPS或NetWork获取当前位置的经纬度
- delphi 获取鼠标当前位置的相对坐标
- swiper使用时在loop下如何获取当前的索引值