1.显示地图、定位、显示当前位置。
导入你需要的功能的头文件,申明全局变量,代理方法等等。
![](http://upload-images.jianshu.io/upload_images/2469843-6d34d99d66dfb830.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
初始化地图,在控制器即将显示额时候打开定位和跟踪用户,这里对参数不懂的话康忙进去都有注释。
![](http://upload-images.jianshu.io/upload_images/2469843-d55a302014c0d807.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
对了。iOS8以后定位需要在info.plist添加以下字段
NSLocationAlwaysUsageDescription 永远访问用户位置
NSLocationWhenInUseUsageDescription 在应用使用期间访问用户位置
根据你的需要只要添加一个就行,类型为String,后面文字没什么用可以不写(第一次定位弹出提示框上面显示的文字)。我看有人两个填了上去一个写YES一个NO。。。坑!!!
![](http://upload-images.jianshu.io/upload_images/2469843-c1ef6c9829a9e818.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
当定位成功后会进行这个回调方法实时获得用户的经纬度
![](http://upload-images.jianshu.io/upload_images/2469843-9552dea61a560479.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
当点击地图上定位annotation时进行反地理编码进行编码查询、获得当前用户的地址位置替换定位的标题和子标题
![](http://upload-images.jianshu.io/upload_images/2469843-2a13f6c93211d844.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](http://upload-images.jianshu.io/upload_images/2469843-ceb7f482b083b413.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](http://upload-images.jianshu.io/upload_images/2469843-ea4bbc83cd931f1a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
效果图如下。。
![](http://upload-images.jianshu.io/upload_images/2469843-4e01a74012113658.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
2.显示用户附近信息
初始化搜索类。获取用户当前位置通过POI周边请求
![](http://upload-images.jianshu.io/upload_images/2469843-c366e3eb26e2759f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](http://upload-images.jianshu.io/upload_images/2469843-f8873f6063696b83.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
回调方法中把poi搜到的地址存到数组中,刷新tableview即可
![](http://upload-images.jianshu.io/upload_images/2469843-35a0f0107600e9d2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
效果图如下