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

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. 我所了解的chrome

    Chrome的隐身模式 先来说说隐身模式的启用方法吧 1.键盘快捷:Ctrl + Shift + N. 2.在Windows7下的任务栏处,右击“Chrome”图标,会出一个下拉菜单,点击“新建隐身窗 ...

  2. Atitit java方法引用(Method References) 与c#委托与脚本语言js的函数指针

    Atitit java方法引用(Method References) 与c#委托与脚本语言js的函数指针   1.1. java方法引用(Method References) 与c#委托与脚本语言js ...

  3. salesforce 零基础学习(二十四)解析csv格式内容

    salesforce中支持对csv格式的内容批量导入,可以使用dataloader,然而有些情况下,当用户没有相关权限使用dataloader导入情况下,就的需要使用VF和apex代码来搞定. 基本想 ...

  4. noip 2016提高组D2T1 problem

    我们可以先预处理一下组合数模K的值,然后我们可以发现对于答案ji[n][m],可以发现递推式ji[i][j]=ji[i-1][j]+ji[i][j-1]-ji[i-1][j-1]并对于Cij是否%k等 ...

  5. Ubuntu14中supervisor的安装及配置

    supervisor是一款很好用的进程管理工具,其命令也很简单,其安装过程如下: Ubuntu14: 首先保证本地的Python环境是OK的,并且已经安装supervisor包,如果没有安装可以用ea ...

  6. 转载:css3 content 生成内容

    本文地址:http://www.w3cplus.com/solution/css3content/css3content.html 这篇文章挺不错的,建议看一下. content一般和:before, ...

  7. 信息加密之消息摘要算法的MAC

    MAC是消息摘要算法的第三种实现方式,另外两种方式分别为:MD2\4\5.SHA. MAC的jdk实现:1.默认密钥方式 private static void MAC_JDK(){ try { Ke ...

  8. HttpClient post json,可以是数组

    var json = JsonConvert.SerializeObject(obj); StringContent theContent = new StringContent(json, Enco ...

  9. linux安装nginx

    nginx启动.重启.关闭 安装: http://www.cnblogs.com/skynet/p/4146083.html 一.启动 cd usr/local/nginx/sbin ./nginx ...

  10. 为网格布局图片打造的超炫 CSS 加载动画

    今天,我想与大家分享一些专门为网格布局的图像制作的很酷的 CSS 加载动画效果.您可以把这些效果用在你的作品集,博客或任何你想要的网页中.设置很简单.我们使用了下面这些工具库来实现这个效果: Norm ...