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

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. Node.js与Sails~项目结构与Mvc实现

    回到目录 Sails是一个Node.js的中间件架构,帮助我们很方便的构建WEB应用程序,网址:http://www.sailsjs.org/,它主要是在Express框架的基础上发展起来的,扩展了新 ...

  2. FIR.im Weekly - 劳动节我们也没有停下来

    五一到五四的节假日对勤劳的开发者们似乎是零存在,各种干货好资源也并未因假期的到来而减少,所以这周的 Weekly 依然多产. Swift 样式指南:2015年4月更新 这是 @开发技术前线 收录的由 ...

  3. html5视频全频播放

    html5视频全频播放 旋转90度 对video进行缩放 修正position 效果还凑合 代码 $(media).rotate({ // angle: 90, duration: 100, anim ...

  4. Sublime快速上手

    在当前的互联网时代,任何程序语言和相关技术都只是实现互联网应用的一种手段,这也就造成了大量的互联网工程师长期与不同的语言.技术.系统环境.IDE等打交道.因此一个相对统一方便的IDE对于程序员来说显得 ...

  5. IO流-文件管理

    File f = new File(“test.txt”); File的构造器不会在文件不存在的情况下新建一个文件,从File对象中创建文件是由文件流的构造器或File类的createNewFile方 ...

  6. NYOJ995硬币找零(简单dp)

    /* 题意:给你不同面额的硬币(每种硬币无限多),需要找零的面值是T,用这些硬币进行找零, 如果T恰好能被找零,输出最少需要的硬币的数目!否则请输出剩下钱数最少的找零方案中的最少硬币数! 思路:转换成 ...

  7. 关于c#动态加载程序集的一些注意事项

    Assembly下有LoadFile,LoadFrom等方法可以加载程序集. LoadFile只加载你给定路径的那个dll,LoadFrom会自动加载依赖的dll. 如:A依赖B,LoadFile(& ...

  8. 如何用分析函数找出EMP表中每个部门工资最高的员工

    EMP表是Oracle测试账户SCOTT中的一张雇员表,首先,我们来看看emp表的数据 SQL> select * from emp; EMPNO ENAME JOB MGR HIREDATE ...

  9. HTML5移动Web开发(十)——在浏览器中启动手机原生应用

    用户可以在浏览器中启动移动设备的原生应用程序,比如地图.电话.短信等,具体能够启动哪些应用程序,这取决于该移动设备上哪些原生应用是否允许从浏览器启动. 新建ch02r05.html <!doct ...

  10. 基于纯 CSS3 技术实现美观的标签云效果

    标签云是博客的标配功能,能够清晰的呈现博客的各个关键词和主题.在这个效果中,您将学习如何使用 CSS3 技术创建一个效果精美的标签云效果. 作为实验项目,使用了 CSS3 渐变,阴影和最重要的的 CS ...