这篇文章将为大家详细讲解有关iOS如何将地址解析成经纬度,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
创新互联建站专注于企业网络营销推广、网站重做改版、佛山网站定制设计、自适应品牌网站建设、H5网站设计、购物商城网站建设、集团公司官网建设、成都外贸网站建设公司、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为佛山等各大城市提供网站开发制作服务。
具体内容如下
一、工程图
二、代码
ViewController.h
#import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> #import <CoreLocation/CLLocationManagerDelegate.h> @interface ViewController : UIViewController <CLLocationManagerDelegate> @end
ViewController.m
#import "ViewController.h" #import <CoreLocation/CoreLocation.h> #import <AddressBook/AddressBook.h> //正编译。将地址解析为经纬度 @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:@"上海徐汇漕溪路" completionHandler:^(NSArray *placemarks, NSError *error){ NSLog(@"查询记录数:%ld",[placemarks count]); if ([placemarks count] > 0) { CLPlacemark *placemark = [placemarks objectAtIndex:0]; CLLocationCoordinate2D coordinate = placemark.location.coordinate; NSString *strCoordinate = [NSString stringWithFormat:@"经度:%3.5f 纬度:%3.5f:",coordinate.latitude,coordinate.longitude ]; NSLog(@"%@",strCoordinate); } }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
关于“iOS如何将地址解析成经纬度”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
网站题目:iOS如何将地址解析成经纬度
当前地址:https://www.cdcxhl.com/article10/iheego.html
成都网站建设公司_创新互联,为您提供动态网站、软件开发、微信小程序、网页设计公司、品牌网站制作、响应式网站
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联