国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 孝义市| 土默特右旗| 双桥区| 县级市| 兴国县| 大余县| 永寿县| 泸西县| 天门市| 五华县| 兴文县| 道真| 财经| 鱼台县| 宿迁市| 洪江市| 吉安市| 察哈| 福海县| 柳州市| 海安县| 高阳县| 澄城县| 门头沟区| 宝兴县| 麻阳| 上犹县| 大丰市| 广丰县| 盐池县| 上蔡县| 宁远县| 凤庆县| 天柱县| 松潘县| 农安县| 丰台区| 张家港市| 大连市| 阳春市| 巴林右旗|