本人开发的开发者技术变现资源聚集地,大家支持下,下面是网址

https://www.baiydu.com

先说下这功能的流程,  流程:判断用户是否联网--->获取用户地理位置经纬度--->通过经纬度去查询地理位置名称

//高德地图
@property (nonatomic, strong) MAMapView *mapView;//高德地图
@property (nonatomic, strong) AMapSearchAPI *search;
@property(nonatomic,strong)NSString *longitude;
@property(nonatomic,strong)NSString *latitude;
@property (nonatomic, strong) CLLocationManager *locationManager; //本地信息存储类
@property(nonatomic,strong) AMapAddressComponent *compantAddress;
@property(nonatomic,strong) NSMutableArray *CellContentArray;
@property(nonatomic,strong)NSString *currentCityName; @property(nonatomic,strong)NSString *tempRecordIsOrNoSelect;//是否是首次加载定位 @end @implementation HomeController
//通知设置值 根据选中的地区加载相应的数据
- (void)setCurrentLocation:(NSNotification *)text{ //移除通知
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"citySelectLocationReciveceMethod" object:nil];
_currentCityName= [NSString stringWithFormat:@"%@",text.object]; if (_currentCityName.length>) {
_currentCityName=[_currentCityName substringToIndex:]; }
else
{ }
_tempRecordIsOrNoSelect=_currentCityName; } -(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
[[AFNetworkReachabilityManager sharedManager] startMonitoring];//开启网络监听
if (self.navigationController.navigationBar.hidden) {
self.navigationController.navigationBarHidden=NO;
} [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setCurrentLocation:) name:@"citySelectLocationReciveceMethod" object:nil];
//地图定位
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
// if (_tempRecordIsOrNoSelect.length==0) {
if(status==AFNetworkReachabilityStatusNotReachable)
{
showMessage(@"请检查网络是否畅通!");
_tempRecordIsOrNoSelect=nil;
[SVProgressHUD dismiss];
return ;
}
else
{
if (_tempRecordIsOrNoSelect.length==) {
[SVProgressHUD showWithStatus:@"定位中......" maskType:SVProgressHUDMaskTypeBlack]; _longitude=[[NSString alloc]init];
_latitude=[[NSString alloc]init];
self.mapView=[[MAMapView alloc]initWithFrame:CGRectMake(, , , )];
self.mapView.userTrackingMode = ,
_mapView.showsUserLocation = YES;
self.mapView.userTrackingMode = MAUserTrackingModeNone;
self.mapView.delegate=self;
}
else
{
CGRect tempLeftButtonFrame=self.LeftButton.frame;
_tempRecordIsOrNoSelect=_currentCityName;
[self setLeftButtonTitle:_currentCityName setFontColor:[UIColor whiteColor] setFontSize: setFrme:&tempLeftButtonFrame]; } } }]; self.title=@"首页"; //高德地图 } //高德地图代理
- (void)mapViewWillStartLocatingUser:(MAMapView *)mapView
{
if(![CLLocationManager locationServicesEnabled]){
UIAlertView * alertView = [[UIAlertView alloc]initWithTitle:@"定位失败" message:@"请在手机设置中开启定位功能\n开启步骤:设置 > 隐私 > 位置 > 定位服务" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alertView show];
self.mapView = nil;
self.mapView.delegate = nil;
return;
}else{ if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorizedAlways) {
UIAlertView * alertView = [[UIAlertView alloc]initWithTitle:@"定位失败" message:@"请在手机设置中开启定位功能\n开启步骤:设置 > 隐私 > 位置 > 定位服务下《***》应用" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alertView show];
self.mapView = nil;
self.mapView.delegate = nil;
return;
}
}
} - (void)mapViewDidStopLocatingUser:(MAMapView *)mapView
{ _longitude=[NSString stringWithFormat:@"%f",mapView.userLocation.location.coordinate.longitude];//@"106.546128";//
_latitude= [NSString stringWithFormat:@"%f",mapView.userLocation.location.coordinate.latitude]; //@"29.559153";
_search = [[AMapSearchAPI alloc] initWithSearchKey:@"e4bb6f15bba9fde10b1cfc13b298370e" Delegate:self];
AMapReGeocodeSearchRequest *regeoRequest = [[AMapReGeocodeSearchRequest alloc] init];
regeoRequest.searchType = AMapSearchType_ReGeocode; regeoRequest.location =[AMapGeoPoint locationWithLatitude:[_latitude floatValue] longitude:[_longitude floatValue]];
regeoRequest.radius = ;
regeoRequest.requireExtension = YES; //发起逆地理编码
[_search AMapReGoecodeSearch: regeoRequest]; }
//逆编码查询代理
- (void)onReGeocodeSearchDone:(AMapReGeocodeSearchRequest *)request response:(AMapReGeocodeSearchResponse *)response
{
if(response.regeocode != nil)
{ _compantAddress=response.regeocode.addressComponent; _currentCityName=_compantAddress.province;
if (_currentCityName.length>) {
_currentCityName=[_currentCityName substringToIndex:];
}
_tempRecordIsOrNoSelect=_currentCityName;//定位后也要给这个临时判断是否选择的变量赋值 [self setLeftButtonTitle:_currentCityName setFontColor:[UIColor whiteColor] setFontSize: setFrme:&computeFrame]; UIImageView *pointView=[[UIImageView alloc]initWithFrame:CGRectMake(computeFrame.size.width-,, , )];
[pointView setImage:[UIImage imageNamed:@"fanhuijiantou.png"]]; [pointView setBackgroundColor:[UIColor clearColor]]; [self.LeftButton addSubview:pointView]; [self.LeftButton addTarget:self action:@selector(changeLocationClick:) forControlEvents:UIControlEventTouchUpInside]; self.LeftButton.hidden=NO; }
else{
showMessage(@"请检查网是否畅通!");
}
[SVProgressHUD dismiss];
}
- (void)mapView:(MAMapView *)mapView didUpdateUserLocation:(MAUserLocation *)userLocation
{ mapView.showsUserLocation = NO; }

本人做的一款androidApp,积分墙下载可兑支付宝红包,无广告看最新国内外大片,各种当前热门H5页游,淘宝天猫高额购物券!!:扫描下载,多谢支持!若有需要做此类产品的可以联系我:2819936788,各类数据API接口!(手机/流量/QB/游戏/淘宝客高额优惠券/超便宜的代理IP API/产品推广工具API)

 

IOS高德地图逆地理编码定位+网络判断的更多相关文章

  1. android studio高德地图的显示于定位(附带逆地理编码围栏)

    首先注册高德成为开发者(打开高德地图,点击底部的开发者平台),创建应用,按照要求填写相应信息 网站:http://lbs.amap.com/api/android-sdk/guide/create-p ...

  2. 【高德地图API】地理编码与逆地理编码

    一.地理编码 该功能实现地理编码服务,即地址匹配,从已知的地址描述到对应的经纬度坐标的转换,即根据地址信息,查询该地址所对应的点坐标等,地址(address) 为必选项,城市(city)为可选项. & ...

  3. 微信小程序地图之逆地理编码

    首先说一下,我微信自带map的api中并没有相关接口可调用.文中的方法建立于高德地图.(顺便吐槽,微信开发文档相比支付宝家的显得好烂!) 最近做项目用到地图定位相关的需求,为了搞定需求看了下相关的文档 ...

  4. iOS高德地图SDK定位和搜索附近信息的具体使用

    1.显示地图.定位.显示当前位置. 导入你需要的功能的头文件,申明全局变量,代理方法等等.   初始化地图,在控制器即将显示额时候打开定位和跟踪用户,这里对参数不懂的话康忙进去都有注释.   对了.i ...

  5. iOS:高德地图的使用

    本人花了点时间集成了高德地图的几乎所有的功能,包含:地图的显示.地图的绘制.地图的定位.地图的POI数据检索.地图的线路规划.地图导航等下载地址如下:https://github.com/xiayua ...

  6. 高德地图api之location定位

    关于定位,分为GPS定位和网络定位.本文将详细描述的浏览器定位,属于网络定位.这是一种通过使用高德JS-API来实现位置定位.城市定位的方法,包含了IP定位,检索等多种网络定位方式.如果您的手机支持G ...

  7. iOS 高德地图轨迹回放的 思路, 及方法

    // 开始,公司要求制作一段跑步轨迹 在地图上的 动画回放, 传入一段经纬度, 开始一想,这不是很简单吗, 高德地图有可以把经纬度转换成坐标点的方法 /** * @brief 将经纬度转换为指定vie ...

  8. iOS高德地图使用-搜索,路径规划

    项目中想加入地图功能,使用高德地图第三方,想要实现确定一个位置,搜索路线并且显示的方法.耗了一番功夫,总算实现了. 效果 WeChat_1462507820.jpeg 一.配置工作 1.申请key 访 ...

  9. Android编程 高德地图 中如何重写 定位按键 的触发事件 (com.amap.api.maps2d.LocationSource)点击定位后不仅定位在地图中心点上而且可以设置地图的缩放大小和提示

    在利用高德地图来编写自己的APP的时候,发现了一种对定位按键的重写方法,那就是利用   com.amap.api.maps2d.LocationSource  接口来重写. 什么是定位按键呢,下图中右 ...

随机推荐

  1. NodeJS系列~第三个小例子,NodeJs与Redis实现高并发的队列存储

    返回目录 众所周知 redis量个强大的缓存组件,可以部署在win32和linux环境之上,它有五大存储结构,其中有一种为列表list,它可以实现quene和stack的功能,即队列和堆栈的功能. r ...

  2. 04- Shell脚本学习--条件控制和循环语句

    条件判断:if语句 语法格式: if [ expression ] then Statement(s) to be executed if expression is true fi 注意:expre ...

  3. Atitit usrQBM1603短信验证码规范

    Atitit usrQBM1603短信验证码规范 短信验证码扩展至短信服务和验证码服务1 主要方法1 参考模板1 短信验证码扩展至短信服务和验证码服务 主要方法 Line 27: public cla ...

  4. Atitit 电子商务订单号码算法(java c# php js 微信

    Atitit 电子商务订单号码算法(java c# php js  微信 1.1. Js版本的居然钱三爷里面没有..只好自己实现了. 1.2. 订单号标准化...长度16位 1.3. 订单号的结构 前 ...

  5. iOS----------使用 Xcode6或Xcode7配置.pch文件

    刚上手 Xcode6/Xcode7 的人,总会发现之前在 6 之前常常会在“利用名-Prefix.pch”这个文件中来配置我们全局要用到的头文件,但是 xcode6 没有了,人家说,这类东西有时候也会 ...

  6. eclipse根据父类打开子类快捷键

    1.打开类 2.双击选中 3.Ctrl+T,打开实现类

  7. TSQL HASHBYTES 用法

    HashBytes 使用Hash 算法,能够产生高质量的Hash值,大幅度提高识别数据相异的准确性,但是HashBytes函数无法提供100%的准确度,如果业务逻辑要求不允许有误差,那么不要使用任何H ...

  8. KendoUI系列:DropDownList

    1.基本使用 1>.创建Input <input id="dropDownList" /> <link href="@Url.Content(&q ...

  9. 关于js中for in和foreach in的区别

    js 中for in 和foreach in的区别 两个的作用都用来遍历对象,但为什么有了for in语句了还要foreach in语句呢,后来看了下foreach in开发的文档,foreach i ...

  10. [java] 汇率换算器实现-插曲1-正则表达式(1)

    [java] 汇率换算器实现-插曲1-正则表达式(1) // */ // ]]> // */ // ]]>   [java] 汇率换算器实现-插曲1-正则表达式(1) Table of C ...