运行效果入下;

2.定位
#import "ViewController.h"
#import <BaiduMapAPI_Map/BMKMapView.h>
#import <BaiduMapAPI_Location/BMKLocationService.h>
@interface ViewController ()<BMKLocationServiceDelegate,BMKMapViewDelegate>
@property (nonatomic,strong) BMKMapView *mapView;//地图视图
@property (nonatomic,strong) BMKLocationService *service;//定位服务
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//初始化地图
self.mapView = [[BMKMapView alloc] initWithFrame:self.view.frame];
self.mapView.delegate =self;
//添加到view上
[self.view addSubview:self.mapView];
//初始化定位
self.service = [[BMKLocationService alloc] init];
//设置代理
self.service.delegate = self;
//开启定位
[self.service startUserLocationService];
// Do any additional setup after loading the view, typically from a nib.
}
#pragma mark -------BMKLocationServiceDelegate
/**
*用户位置更新后,会调用此函数
*@param userLocation 新的用户位置
*/
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation {
//展示定位
self.mapView.showsUserLocation = YES;
//更新位置数据
[self.mapView updateLocationData:userLocation];
//获取用户的坐标
self.mapView.centerCoordinate = userLocation.location.coordinate;
self.mapView.zoomLevel =18;
}
运行结果

POI检索
#import "ViewController.h"
#import <BaiduMapAPI_Map/BMKMapView.h>
#import <BaiduMapAPI_Location/BMKLocationService.h>
#import <BaiduMapAPI_Search/BMKPoiSearch.h>
#import <BaiduMapAPI_Map/BMKAnnotation.h>
#import <BaiduMapAPI_Map/BMKPointAnnotation.h>
#import <BaiduMapAPI_Map/BMKPinAnnotationView.h>
#define kWidth [UIScreen mainScreen].bounds.size.width
@interface ViewController ()<BMKLocationServiceDelegate,BMKPoiSearchDelegate,BMKMapViewDelegate>
@property (nonatomic,strong) BMKMapView *mapView;//地图视图
@property (nonatomic,strong) BMKLocationService *service;//定位服务
@property (nonatomic,strong) BMKPoiSearch *poiSearch;//搜索服务
@property (nonatomic,strong) NSMutableArray *dataArray;
@end
@implementation ViewController
- (NSMutableArray *)dataArray {
if (!_dataArray) {
_dataArray = [NSMutableArray array];
}
return _dataArray;
}
- (void)viewDidLoad {
[super viewDidLoad];
//初始化地图
self.mapView = [[BMKMapView alloc] initWithFrame:self.view.frame];
self.mapView.delegate =self;
// //设置地图的显示样式
// self.mapView.mapType = BMKMapTypeSatellite;//卫星地图
//
// //设置路况
// self.mapView.trafficEnabled = YES;
//
// //底图poi标注
// self.mapView.showMapPoi = NO;
//
// //在手机上当前可使用的级别为3-21级
// self.mapView.zoomLevel = 21;
//
// //旋转
// self.mapView.rotateEnabled = NO;
//
// //拖拽
// self.mapView.scrollEnabled = NO;
//
[self.view addSubview:self.mapView];
//初始化定位
self.service = [[BMKLocationService alloc] init];
//设置代理
self.service.delegate = self;
//开启定位
[self.service startUserLocationService];
// Do any additional setup after loading the view, typically from a nib.
}
#pragma mark -------BMKLocationServiceDelegate
/**
*用户位置更新后,会调用此函数
*@param userLocation 新的用户位置
*/
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation {
//展示定位
self.mapView.showsUserLocation = YES;
//更新位置数据
[self.mapView updateLocationData:userLocation];
//获取用户的坐标
self.mapView.centerCoordinate = userLocation.location.coordinate;
self.mapView.zoomLevel =18;
//初始化搜索
self.poiSearch =[[BMKPoiSearch alloc] init];
self.poiSearch.delegate = self;
//初始化一个周边云检索对象
BMKNearbySearchOption *option = [[BMKNearbySearchOption alloc] init];
//索引 默认为0
option.pageIndex = 0;
//页数默认为10
option.pageCapacity = 50;
//搜索半径
option.radius = 200;
//检索的中心点,经纬度
option.location = userLocation.location.coordinate;
//搜索的关键字
option.key










