IOS高德地图逆地理编码定位+网络判断
本人开发的开发者技术变现资源聚集地,大家支持下,下面是网址
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高德地图逆地理编码定位+网络判断的更多相关文章
- android studio高德地图的显示于定位(附带逆地理编码围栏)
首先注册高德成为开发者(打开高德地图,点击底部的开发者平台),创建应用,按照要求填写相应信息 网站:http://lbs.amap.com/api/android-sdk/guide/create-p ...
- 【高德地图API】地理编码与逆地理编码
一.地理编码 该功能实现地理编码服务,即地址匹配,从已知的地址描述到对应的经纬度坐标的转换,即根据地址信息,查询该地址所对应的点坐标等,地址(address) 为必选项,城市(city)为可选项. & ...
- 微信小程序地图之逆地理编码
首先说一下,我微信自带map的api中并没有相关接口可调用.文中的方法建立于高德地图.(顺便吐槽,微信开发文档相比支付宝家的显得好烂!) 最近做项目用到地图定位相关的需求,为了搞定需求看了下相关的文档 ...
- iOS高德地图SDK定位和搜索附近信息的具体使用
1.显示地图.定位.显示当前位置. 导入你需要的功能的头文件,申明全局变量,代理方法等等. 初始化地图,在控制器即将显示额时候打开定位和跟踪用户,这里对参数不懂的话康忙进去都有注释. 对了.i ...
- iOS:高德地图的使用
本人花了点时间集成了高德地图的几乎所有的功能,包含:地图的显示.地图的绘制.地图的定位.地图的POI数据检索.地图的线路规划.地图导航等下载地址如下:https://github.com/xiayua ...
- 高德地图api之location定位
关于定位,分为GPS定位和网络定位.本文将详细描述的浏览器定位,属于网络定位.这是一种通过使用高德JS-API来实现位置定位.城市定位的方法,包含了IP定位,检索等多种网络定位方式.如果您的手机支持G ...
- iOS 高德地图轨迹回放的 思路, 及方法
// 开始,公司要求制作一段跑步轨迹 在地图上的 动画回放, 传入一段经纬度, 开始一想,这不是很简单吗, 高德地图有可以把经纬度转换成坐标点的方法 /** * @brief 将经纬度转换为指定vie ...
- iOS高德地图使用-搜索,路径规划
项目中想加入地图功能,使用高德地图第三方,想要实现确定一个位置,搜索路线并且显示的方法.耗了一番功夫,总算实现了. 效果 WeChat_1462507820.jpeg 一.配置工作 1.申请key 访 ...
- Android编程 高德地图 中如何重写 定位按键 的触发事件 (com.amap.api.maps2d.LocationSource)点击定位后不仅定位在地图中心点上而且可以设置地图的缩放大小和提示
在利用高德地图来编写自己的APP的时候,发现了一种对定位按键的重写方法,那就是利用 com.amap.api.maps2d.LocationSource 接口来重写. 什么是定位按键呢,下图中右 ...
随机推荐
- 什么是P3O?
P3O(Portfolio, Programme and Project Offices)项目组合.项目群和项目办公室资格认证. 是由英国商务部 OGC 于2008年10月28日发布的最新的最佳实践指 ...
- Zabbix安装部署
zabbix服务器端配置:(10.27.98.29服务器端) 1.安装lamp环境 yum -y install autoconf curl-devel gcc gcc-c++ httpd httpd ...
- flow.ci Beta 上线,将开发工作流自动化
说起未来,我们会想到自动.智能.机器人...,希望可以从眼前重复繁琐的事情中解放出来,让"机器人"自动智能地帮我们做更多的事情:希望开发可以更自动化.智能化.社会化,更少的资源浪费 ...
- easyui combotree下拉框多选赋值
发现jquery.easyui.min.js 1.3.4版本的用setValues给多选下拉框赋值不成功,只能用1.3.1版本的 Html代码: <input id="ProductL ...
- rabbitMQ第四篇:远程调用
前言:前面我们讲解的都是本地服务器,现在如果需要远程计算机上运行一个函数,等待结果.这就是一个不同的故事了,这种模式通常被称为远程过程调用或者RPC. 本章教程我们使用RabbitMQ搭建一个RPC系 ...
- Apache Tomcat
官网:http://tomcat.apache.org/ Documentation:http://tomcat.apache.org/tomcat-8.0-doc/index.html
- CSS中模拟父元素选择器
很多情况下,我们需要找到父元素,但可惜的是css中并没有这样的一个选择器. 至于原因可以看张鑫旭的如何在CSS中实现父选择器效果这篇文章. 简单来说这个实现并不是真正的父元素选择器,只是利用其它思路来 ...
- 编译原理简单语法分析器(first,follow,分析表)源码下载
编译原理(简单语法分析器下载) http://files.cnblogs.com/files/hujunzheng/%E5%8A%A0%E5%85%A5%E5%90%8C%E6%AD%A5%E7%AC ...
- 【原创】.NET读写Excel工具Spire.Xls使用(3)单元格控制
本博客所有文章分类的总目录:http://www.cnblogs.com/asxinyu/p/4288836.html .NET读写Excel工具Spire.Xls使用文章 ...
- 修改NLS_DATE_FORMAT的四种方式
一. 在用户环境变量中指定(LINUX) 在用户的.bash_profile中增加两句: export NLS_LANG=AMERICAN ---这一句必须指定,否则下一句不生效.export NLS ...