国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

iOS將地址解析成經緯度的方法

2020-07-26 02:43:46
字體:
來源:轉載
供稿:網友

本文實例為大家分享了iOS將地址解析成經緯度的具體代碼,供大家參考,具體內容如下

一、工程圖

二、代碼

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

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 那坡县| 贞丰县| 宣威市| 巩留县| 剑阁县| 铁岭市| 西平县| 习水县| 凯里市| 阿拉尔市| 肥乡县| 卫辉市| 大兴区| 普陀区| 获嘉县| 汽车| 宁津县| 吴堡县| 华坪县| 上蔡县| 龙岩市| 连云港市| 什邡市| 定边县| 依安县| 景谷| 剑川县| 东丽区| 云梦县| 锡林郭勒盟| 堆龙德庆县| 庆元县| 囊谦县| 江都市| 尉氏县| 富宁县| 东乡县| 新安县| 苗栗市| 囊谦县| 资兴市|