【问题标题】:Find location in iPhone by name (duplicate) [closed]按名称在 iPhone 中查找位置(重复)[关闭]
【发布时间】:2014-10-13 12:30:08
【问题描述】:

我是 iOS 应用程序开发的新手。 所以,我想问一下如何通过名称获取位置坐标。

【问题讨论】:

标签: ios objective-c iphone


【解决方案1】:

您可以使用CLGeocoder 获取位置坐标(Forward geoCoding)。

CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:YOUR_LOCATION completionHandler:^(NSArray* placemarks, NSError* error)
         {
             NSLog(@"completed");
             if ( error )
             {
                 NSLog(@"error = %@", error );
             }
             else
             {
                 //Here you get information about the place in placemarks array
             }
         }];

参考Link

【讨论】:

  • 感谢您的帮助,并为我的问题投票,以便我也为您投票。谢谢。
  • 它有效。亲爱的,万岁谢谢。
  • 谢谢。再次苏海尔。
【解决方案2】:

您想获取用户位置并显示它还是希望用户输入地址然后显示该地址的坐标?

在 iOS7(或更早版本)中获取用户位置: http://ios-blog.co.uk/tutorials/getting-the-users-location-using-corelocation/

对于 iOS8 你需要做一些小的调整: http://matthewfecher.com/app-developement/getting-gps-location-using-core-location-in-ios-8-vs-ios-7/

如果你想要一个地址的坐标,你可以使用 CLGeocoder 的这个方法:

- (void)geocodeAddressString:(NSString *)addressString completionHandler:(CLGeocodeCompletionHandler)completionHandler

不幸的是,这在美国以外的地方效果不佳。您可以使用其他服务,但使用它们会花费您一些钱。请查看此线程以获取更多信息:Get Coordinates for given Location

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-03
    • 2013-11-07
    • 1970-01-01
    • 1970-01-01
    • 2014-07-29
    • 1970-01-01
    • 2016-08-23
    • 2014-06-02
    相关资源
    最近更新 更多