iOS开发中的 地区转经纬 经纬度转地区

news/2024/7/2 23:53:59

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

参考

iOS 根据地名获取经纬度

iOS 根据经纬度显示地名

- (void)setCity {[[LoginUserInfo sharedLoginUserInfo] latitude];NSLog(@"%@",[[LoginUserInfo sharedLoginUserInfo] latitude]);NSLog(@"------%@",[[LoginUserInfo sharedLoginUserInfo] longitude]);CLLocationCoordinate2D coordinate;coordinate.latitude = [[NSString stringWithFormat:@"%@",[[LoginUserInfo sharedLoginUserInfo] latitude]] floatValue];coordinate.longitude = [[NSString stringWithFormat:@"%@",[[LoginUserInfo sharedLoginUserInfo] longitude]] floatValue];CLLocation * newLocation = [[CLLocation alloc] initWithLatitude:coordinate.latitude longitude:coordinate.longitude];NSLog(@"%f",coordinate.latitude);NSLog(@"------%f",coordinate.longitude);CLGeocoder *clGeoCoder = [[CLGeocoder alloc] init];[clGeoCoder reverseGeocodeLocation:newLocation completionHandler: ^(NSArray *placemarks,NSError *error) {CLPlacemark*placemark = [placemarks objectAtIndex:0];NSString * LocationAddress = [NSString stringWithFormat:@"%@%@%@%@", placemark.locality, placemark.subLocality,placemark.thoroughfare, placemark.subThoroughfare];NSLog(@"%@",LocationAddress);NSLog(@"%@",placemark.locality);if (placemark.locality) {NSMutableString * str = [[NSMutableString alloc] initWithString:placemark.locality];[self setcity:[str substringToIndex:str.length-1]];}//}];
}
- (void)addressPicker:(BAddressPickerController *)addressPicker didSelectedCity:(NSString *)city{NSLog(@"%@",city);CLGeocoder *myGeocoder = [[CLGeocoder alloc] init];[myGeocoder geocodeAddressString:city completionHandler:^(NSArray *placemarks, NSError *error) {if ([placemarks count] > 0 && error == nil) {NSLog(@"Found %lu placemark(s).", (unsigned long)[placemarks count]);CLPlacemark *firstPlacemark = [placemarks objectAtIndex:0];NSLog(@"Longitude = %f", firstPlacemark.location.coordinate.longitude);NSLog(@"Latitude = %f", firstPlacemark.location.coordinate.latitude);//获取经度NSString *longgitudeStr = nil;longgitudeStr = [NSString stringWithFormat:@"%3.5f",firstPlacemark.location.coordinate.longitude];//获取纬度NSString *latitudeStr = nil;latitudeStr = [NSString stringWithFormat:@"%3.5f",firstPlacemark.location.coordinate.latitude];// 保存用户的当前位置//开始定位[[LoginUserInfo sharedLoginUserInfo] setLatitude:latitudeStr]; // 纬度[[LoginUserInfo sharedLoginUserInfo] setLongitude:longgitudeStr]; // 经度}else if ([placemarks count] == 0 && error == nil) {NSLog(@"Found no placemarks.");} else if (error != nil) {NSLog(@"An error occurred = %@", error);}}];[self.delegate setcity:city];[self dismissViewControllerAnimated:YES completion:nil];}

这是两个文件里面的具体使用,大家可以参考

转载于:https://my.oschina.net/bieshixuan/blog/611288


http://lihuaxi.xjx100.cn/news/286085.html

相关文章

求一个数的因子个数/因子和/质因子 C/C++实现

求一个数的因子个数时间复杂度O√n ll get_number(ll x){ll num0;for(ll i1;i*i<x;i){if(x%i0) num2; if(i*ix) num1;}return num; }求一个数的因子和时间复杂度O√n ll get_number(ll x){ll num0;for(ll i1;i*i<x;i){if(x%i0) numix/i;if(i*ix) numi;}return num…

poj1422(最小路径覆盖问题)

最小路径覆盖数: 对于一个DAG&#xff08;有向无环图&#xff09;&#xff0c;选取最少条路径&#xff0c;使得每个 顶点属于且仅属于一条路径。路径长度可以为零&#xff1b;&#xff08;有向图中找一些路径&#xff0c;使之覆盖了图中的所有顶点&#xff0c;就是任意一个顶点…

主席树 ---- CF 1422F. Boring Queries(由离线推出在线如何求的 ,求解多次询问的区间LCM)

题目链接 题目大意&#xff1a; 给你nnn个数&#xff0c; 每次往第iii个数里面里面乘aaa&#xff0c;问你这nnn个数的LCM\text{LCM}LCM是多少&#xff1f; 解题思路&#xff1a; 多个数的lcm不是所有数的乘积除以所有数的gcd&#xff0c;如 4 8 3 正确求法是每个数分解质因数…

春节停车难?用Python找空车位

作者 | Adam Geitgey译者 | 风车云马整理 | Jane出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09;【导语】今天这篇文章的选题非常贴近生活。营长生活在北京&#xff0c;深知开车出门最怕的就是堵车和找不到停车位。记得冬至那个周末&#xff0c;几个小伙伴滑雪回来找…

汉字风格迁移篇--中文字体的多任务对抗学习

文章目录 摘要存在的问题提出一种方法INTRODUCTION汉字生成背景RELATED WORK现有的一些方法基于CG的方法存在的问题METHOD DESCRIPTIONA、Problem F ormulationB、Base ModelC、MTfontGAN Network AchitecturesD、Objective FunctionE. Training ProcessEXPERIMENTSA、Experime…

poj2594(最小可相交覆盖路径问题)

最小可相交覆盖&#xff1a; 先用floyd求出原图的传递闭包&#xff0c;即如果a->b有路径&#xff0c;b->c有路径&#xff0c;&#xff0c;则加边a->c。然后就转化成了最小路径覆盖问题&#xff08;最小不相交路径覆盖问题&#xff09;。 最小路径覆盖数: 对于一个DAG&…

子段乘积(逆元费马小定理)+线段树做法

题解&#xff1a;一开始做这个题的时候想过尺取法&#xff0c;但是因为没有逆元的知识&#xff0c;不知道该如何不断删除左端元素。其实这题并不难想&#xff0c;设l&#xff0c;r为两端开始都置为1&#xff0c;当长度小于k的时候不断乘右端元素并取余&#xff0c;当长度等于k时…

javascript --- 事件托付

javascript 之 事件托付 长处&#xff1a;1、提高性能&#xff08;仅仅须要对父级进行操作&#xff0c;子节点相同会拥有其相关属性和方法&#xff09; 2、对于新加入的事件。也让其拥有父级事件的属性 <!doctype html> <html lang"en"> <head><…