IOS百度地图获取所在的城市名称
笔者的app要实现定位所在省和城市名称,借此总结巩固一下!
@interface VenueListVC : BasePageTableViewVC<BMKLocationServiceDelegate,BMKGeoCodeSearchDelegate> {
BMKLocationService *_locService;
BMKGeoCodeSearch *_geoSearch;
float _curLatitude, _curLongitude;
NSString *_curCityName,*_curProName;
- (void)viewDidLoad {
//百度地图定位
if (![CLLocationManager locationServicesEnabled]) {
[UIAlertView showMsg:@"请在“系统设置”中开启定位服务" cancelText:@"确定" cancelAction:^{
[self onBackButtonClick:nil];
} okText:nil okAction:nil];
return;
}
//初始化BMKLocationService
if (_locService == nil) {
_locService = [[BMKLocationService alloc]init];
}
_locService.delegate = self;
//启动LocationService
[_locService startUserLocationService];
_geoSearch = [[BMKGeoCodeSearch alloc] init];
//编码服务的初始化(就是获取经纬度,或者获取地理位置服务)
_geoSearch.delegate = self;//设置代理为self
// [self showProgressHUDWithText:@"正在定位..."];
}
//反向地理编码
-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
{
if (error == ) {
BMKPointAnnotation* item = [[BMKPointAnnotation alloc]init];
item.coordinate = result.location;
item.title = result.address;
NSString* titleStr;
NSString* showmeg;
titleStr = @"反向地理编码";
showmeg = [NSString stringWithFormat:@"%@",item.title];
_curCityName = result.addressDetail.city;
_curProName = result.addressDetail.province;
NSLog(result);
} }
//处理位置坐标更新
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
[_locService stopUserLocationService]; CLLocationCoordinate2D coor;
coor=userLocation.location.coordinate;
_curLatitude = coor.latitude;
_curLongitude = coor.longitude; CLLocationCoordinate2D pt = (CLLocationCoordinate2D){_curLatitude, _curLongitude};
BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
reverseGeocodeSearchOption.reverseGeoPoint = pt;
[_geoSearch reverseGeoCode:reverseGeocodeSearchOption]; } /**
*定位失败后,会调用此函数
*@param error 错误号
*/
- (void)didFailToLocateUserWithError:(NSError *)error {
[_locService stopUserLocationService];
[self hideProgressHUD];
}
IOS百度地图获取所在的城市名称的更多相关文章
- iOS 百度地图获取当前地理位置
// // ViewController.m // BaiDuDemo // // Created by Chocolate. on 15-3-2. // Copyright (c) 2015年 re ...
- IOS百度地图之--->第一篇《环境配置与基本使用》
Ios 百度地图SDK简易使用说明:http://developer.baidu.com/map/index.php?title=iossdk 先道歉:对于原来上传的Demo我很抱歉,什么都没有,也没 ...
- iOS百度地图简单使用详解
iOS百度地图简单使用详解 百度地图 iOS SDK是一套基于iOS 5.0及以上版本设备的应用程序接口,不仅提供展示地图的基本接口,还提供POI检索.路径规划.地图标注.离线地图.定位.周边雷达等丰 ...
- iOS百度地图SDK集成详细步骤
1.iOS百度地图下载地址 http://developer.baidu.com/map/index.php?title=iossdk/sdkiosdev-download 根据需要选择不同的版本 ...
- vue 中结合百度地图获取当前城市
首先需要去百度地图开发者平台申请 ak http://lbsyun.baidu.com/index.php?title=%E9%A6%96%E9%A1%B5 在index.html 中引入script ...
- 通过jquery 获取用户当前所在的城市名称和IP地址
下面这段JS代码是通过jquery 结合新浪IP地址库和QQip地址库接口获取用户当前所在的城市(省份)名称. 用户当前IP地址等数据.其中当前IP是通过 QQip地址库接口获取,其他数据都是通过 新 ...
- iOS百度地图探索
新建工程后,几项准备: 1.工程中一个文件设为.mm后缀 2.在Xcode的Project -> Edit Active Target -> Build -> Linking -&g ...
- iOS百度地图路径规划和POI检索详细总结-b
路径规划.png 百度地图的使用 百度地图API的导入网上说了许多坑,不过我遇到的比较少,这里就放两个比较常见的吧.坑一: 奥联WIFI_xcodeproj.png 如上图所示,在infoplist里 ...
- iOS百度地图简单使用
本文介绍三种接口: 1.基础地图2.POI检索3.定位 首先是配置环境,有两种方法,方法在官方教程里都有,不再多说 1.使用CocoaPods自动配置[这个方法特别好,因为当你使用CocoaPods配 ...
随机推荐
- Apache Commons BeanUtils
http://commons.apache.org/proper/commons-beanutils/javadocs/v1.9.2/apidocs/org/apache/commons/beanut ...
- 网上找的Gif图片解析类
这个是搜到的大部分的答案 下面贴出来代码 public class MyGifView extends View { private long movieStart; private Movie mo ...
- web api+递归树型结构
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Ne ...
- 【JAVA】【leetcode】【使用堆栈实现后向计算】
题目:evaluate-reverse-polish-notation 要求: Evaluate the value of an arithmetic expression in Reverse Po ...
- css新增样式
一. box-shadow(阴影效果)使用:box-shadow: 20px 10px 0 #000;-moz-box-shadow: 20px 10px 0 #000;-webkit-box-sha ...
- VC界面最前端显示
//显示在最前端 m_pMainWnd->SetWindowPos(&CWnd::wndTopMost, 0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); if (m_pM ...
- 怎么让我们自己开发的Android程序设为默认启动
怎么让我们自己开发的Android程序设为默认启动呢?其实很简单,只要在AndroidManifest.xml文件中配置一下首次启动的那个Activity即要. <activity ...
- 【翻译】configuration changes与handler.post
原文地址 http://corner.squareup.com/2013/12/android-main-thread-2.html 在前一部分里面previous part ,我们深入挖掘了 loo ...
- 虚拟机解决Device eth0 does not seem to be present 问题。
Device eth0 does not seem to be present... 出现这个问题基本上是因为虚拟机是克隆的导致机器的mac网卡不一致,所以系统识别网卡失败:
- Xcode真机调试出现The account '***' has no team with ID '***'的解决方案
前段时间,想用真机调试的时候出现 The account '***' has no team with ID '***'的问题, 以前页真机调试过,没有这种情况,于是我登陆开发者中心,进去发现说我的账 ...