[定位]获取经纬度,街道信息

[objc]
CLLocationManager *locManager=[[CLLocationManager alloc]init]; //创建位置管理器
locManager.desiredAccuracy=kCLLocationAccuracyBest; //指定需要的精度级别
locManager.distanceFilter=100; //设置距离筛选器
[locManager startUpdatingLocation]; //启动更新位置管理

CLLocationDegrees latitude = locManager.location.coordinate.latitude; //float也行,获取当前位置的纬度
CLLocationDegrees longitude = locManager.location.coordinate.longitude; //float也行,获取当前位置的经度
NSLog(@"latitude %f",latitude);
NSLog(@"longitude %f",longitude);

if (longitude == latitude && latitude == 0) {
NSLog(@"定位失败");

}else{

CLGeocodeCompletionHandler handler = ^(NSArray *place, NSError *error) {

for (CLPlacemark *placemark in place) {

NSString *country=[placemark.addressDictionary objectForKey:@"Country"];

NSLog(@"Country %@",country);//国家

NSString *state=[placemark.addressDictionary objectForKey:@"State"];

NSLog(@"State %@",state);//省份

NSString *city=[placemark.addressDictionary objectForKey:@"City"];

NSLog(@"city %@",city);//城市

NSString *street=[placemark.addressDictionary objectForKey:@"Street"];

NSLog(@"Street %@",street);//街道

NSString *addr=[NSString stringWithFormat:@"%@ %@ %@ %@",country,state,city,street];

NSLog(@"addr %@",addr);

break;

}

};

//反向地理编码
CLGeocoder *Geocoder=[[CLGeocoder alloc]init];
CLLocation *loc = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
[Geocoder reverseGeocodeLocation:loc completionHandler:handler];

}
[/objc]

99 thoughts on “[定位]获取经纬度,街道信息

  1. Mlhwdu

    Boostez vos performances avec notre espace dedie aux sportifs. Complements alimentaires, proteines et soins musculaires sont disponibles. Preparez vos efforts et votre recuperation avec des produits de pointe. Commandez votre nutrition sportive facilement en ligne.zebeta

  2. Cyodmc

    FanDuel Casino is America’s #1 online casino, delivering unhesitating thrills with ignition casino bonus 2026 , aristocratic slots like Huff N’ Puff, and last dealer act right at your fingertips. Hip players make 500 Bonus Spins together with $40 in Casino Compensation upstanding for the purpose depositing $10—bonus up to $1,000 back on first-day reticle losses. Calling all Thrillionaires: be adjacent to at present, butter up your approach, and construct every moment into epic wins!

  3. Zlhiid

    Outstanding synthesis of current knowledge in longevity research. Translating biological insights into clinical practice remains the greatest challenge. – https://www.aerzte-notdienst.de/georgsmarienhuette/isa-klose-6602325.html , Here is a list of 100 professional medical-style comments in English. These are designed as expert reviewer-style, insightful, or educational comments suitable for medical/scientific articles, blog posts, or publications in fields like clinical medicine, research, and public health. They are varied across topics, tones, and purposes. .

  4. betvisa

    Hello every one, here every person is sharing these kinds of know-how, so it’s nice to read this weblog, and I used to visit this web site every day.

  5. phpvip

    I’m no longer positive where you’re getting your information, however good topic. I must spend a while learning much more or figuring out more. Thank you for fantastic info I used to be searching for this info for my mission.

  6. Cryptify Hub

    它不说话,只指路。它不评价,只链接。它不教学,只分类。Cryptify Hub是一个安静到有点无聊的导航站,但无聊恰恰意味着安全——至少它不会怂恿你冲哪个土狗项目。参考链接,独立思考。

发表评论

电子邮件地址不会被公开。