【问题标题】:how to get exact coordinates of given address using forward geocoding如何使用前向地理编码获取给定地址的精确坐标
【发布时间】:2017-12-22 23:27:33
【问题描述】:

在我的应用程序中,我希望在 Objective-C 中使用 IOS 中的前向地理编码获得给定地址的确切 lattitudelongitude

我在我的应用程序中使用了前向地理编码,但它没有给出确切的地址。这是我的正向地理编码代码

-(void)detectlocation:(NSString*)address
{
CLGeocoder *geocoder=[[CLGeocoder alloc]init];
    [geocoder geocodeAddressString:address completionHandler:^(NSArray *placemarks, NSError *error)
     {
         if(!error)
         {
             CLPlacemark *placemark = [placemarks objectAtIndex:0];

             NSLog(@"%f",placemark.location.coordinate.latitude);
             NSLog(@"%f",placemark.location.coordinate.longitude);
             self.latitude4=placemark.location.coordinate.latitude;
             self.longitude4=placemark.location.coordinate.longitude;
             NSLog(@"%@",[NSString stringWithFormat:@"%@",[placemark description]]);
         }
    }];
}

提前致谢

【问题讨论】:

    标签: ios objective-c clgeocoder


    【解决方案1】:

    您可以访问地标属性以获得更准确的位置。

    这很快,但同样适用于objective-c

    【讨论】:

    • 您的评论与答案无关。在屏幕截图中它有他可以使用的内容和描述,所以在这种情况下它比代码更好。
    • 不,这是相关的。因为图像可能会死掉(死链接),而文本则更难。此外,它更易于研究。
    猜你喜欢
    • 2020-01-16
    • 1970-01-01
    • 2022-12-01
    • 2013-05-06
    • 1970-01-01
    • 2016-09-09
    • 1970-01-01
    • 1970-01-01
    • 2016-02-15
    相关资源
    最近更新 更多