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

首頁 > 系統(tǒng) > iOS > 正文

iOS將地址解析成經(jīng)緯度的方法

2019-10-21 18:45:04
字體:
供稿:網(wǎng)友

本文實(shí)例為大家分享了iOS將地址解析成經(jīng)緯度的具體代碼,供大家參考,具體內(nèi)容如下

一、工程圖

iOS,地址,經(jīng)緯度

二、代碼

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>//正編譯。將地址解析為經(jīng)緯度@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(@"查詢記錄數(shù):%ld",[placemarks count]);    if ([placemarks count] > 0) {      CLPlacemark *placemark = [placemarks objectAtIndex:0];      CLLocationCoordinate2D coordinate = placemark.location.coordinate;            NSString *strCoordinate = [NSString stringWithFormat:@"經(jīng)度:%3.5f 緯度:%3.5f:",coordinate.latitude,coordinate.longitude ];      NSLog(@"%@",strCoordinate);    }  }];}- (void)didReceiveMemoryWarning {  [super didReceiveMemoryWarning];  // Dispose of any resources that can be recreated.}@end

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持VEVB武林網(wǎng)。


注:相關(guān)教程知識閱讀請移步到IOS開發(fā)頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 无为县| 盐池县| 武城县| 略阳县| 环江| 衡山县| 介休市| 永寿县| 阜宁县| 汶川县| 温州市| 昂仁县| 曲周县| 如东县| 淮安市| 淄博市| 蒲江县| 遵义市| 永胜县| 咸阳市| 苍山县| 海阳市| 会理县| 宣恩县| 南阳市| 洛隆县| 庆城县| 阿尔山市| 孟村| 禄丰县| 海晏县| 崇文区| 宝坻区| 民丰县| 宜宾县| 高淳县| 永年县| 玉龙| 合肥市| 那坡县| 渭南市|