相关疑难解决方法(0)

在iOS中获取纬度和经度的位置名称

我想从纬度和经度中找到当前位置名称,

这里是我的代码片段我试过,但我的日志显示,除了在所有的地方空值placemark,placemark.ISOcountryCodeplacemark.country

我想要的价值placemark.locality,并placemark.subLocality却是露出空值.

- (void)viewWillAppear:(BOOL)animated
{
     [super viewWillAppear:animated];

    // this creates the CCLocationManager that will find your current location
    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
    [locationManager startUpdatingLocation];

}

// this delegate is called when the app successfully finds your current location
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    [geocoder reverseGeocodeLocation:locationManager.location
                   completionHandler:^(NSArray *placemarks, NSError *error) {
                       NSLog(@"reverseGeocodeLocation:completionHandler: Completion Handler called!"); …
Run Code Online (Sandbox Code Playgroud)

iphone reverse-geocoding cllocationmanager ipad ios

16
推荐指数
3
解决办法
4万
查看次数

CLGeocoder和向后兼容性

我有一个简单的问题.

MKReverseCoder已弃用,自iOS 5起无效.我们必须使用CLGeocoder.但是,iOS4下有很多人.新应用如何与iOS4和iOS5配合使用进行地理编码?

谢谢!

iphone backwards-compatibility reverse-geocoding ios5

6
推荐指数
2
解决办法
5953
查看次数

如何在IOS中使用经度和经度通过CLlocationManager获取城市名称?

我试图通过CLLocationManager使用纬度和经度获取地址,但它只返回州和国家名称,我也想要城市,我附加我的代码可以任何人告诉我,我怎么能改变我的代码以获得城市名称.Below是我的代码

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    currentLocation = [locations objectAtIndex:0];
    CLGeocoder *geocoder1 = [[CLGeocoder alloc] init];

     NSLog(@"Detected Location : %f, %f", currentLocation.coordinate.latitude, currentLocation.coordinate.longitude);

    //CLLocation *newLocation = [[CLLocation alloc]initWithLatitude:26.9260 longitude:75.8235];

    CLLocation *newLocation = [[CLLocation alloc]initWithLatitude:currentLocation.coordinate.latitude longitude:currentLocation.coordinate.longitude];

    [geocoder1 reverseGeocodeLocation:newLocation
                   completionHandler:^(NSArray *placemarks, NSError *error) {

                       if (error) {
                           NSLog(@"Geocode failed with error: %@", error);
                           return;
                       }

                       if (placemarks && placemarks.count > 0)
                       {
                           CLPlacemark *placemark = placemarks[0];

                           NSDictionary *addressDictionary =
                           placemark.addressDictionary;

                           NSLog(@"%@ ", addressDictionary);
                           NSString *address = [addressDictionary
                                                objectForKey:(NSString *)kABPersonAddressStreetKey];
                           NSString *city …
Run Code Online (Sandbox Code Playgroud)

city cllocationmanager ios

6
推荐指数
1
解决办法
6762
查看次数