OC简单使用百度地图

这篇博客介绍了如何在Objective-C项目中集成并使用百度地图SDK。首先,通过pod安装百度地图库;其次,将AppDelegate.m转换为AppDelegate.mm,并设置必要的API密钥;最后,创建BaiduMapViewController来展示地图功能。
摘要由CSDN通过智能技术生成

1.使用pod获取百度地图SDK:

pod 'BaiduMapKit'
pod install

2.修改AppDelegate.m 为AppDelegate.mm,在AppDelegate.mm文件中配置key:

/**配置百度地图 需引入头文件(<BaiduMapAPI_Map/BMKMapComponent.h>)*/
    BMKMapManager *manager = [[BMKMapManager alloc]init];
    BOOL ret = [manager start:@"QyyYNtdIRObLlCduZjBY7N2RkOOCcqPC" generalDelegate:self];
    if (!ret) {
        NSLog(@"百度地图开启失败");
    }

3.创建BaiduMapViewController控制器:

#import "BaiduMapViewController.h"
@interface BaiduMapViewController ()<BMKMapViewDelegate,BMKLocationServiceDelegate,UITextFieldDelegate,UITableViewDelegate,UITableViewDataSource,BMKPoiSearchDelegate,BMKGeoCodeSearchDelegate>
/**地图 需引入头文件(<BaiduMapAPI_Map/BMKMapView.h>)*/
@property (nonatomic, strong)BMKMapView *mapView;
/**用户定位*/
@property (nonatomic, strong)BMKUserLocation *userLocation;
/**定位服务 需引入头文件(<BaiduMapAPI_Location/BMKLocationComponent.h>)*/
@property (nonatomic, strong)BMKLocationService *locationService;
/**POI搜索服务 需引入头文件(<BaiduMapAPI_Search/BMKPoiSearch.h>)*/
@property (nonatomic, strong)BMKPoiSearch *search;
/**地理搜索 需要引入头文件<BaiduMapAPI_Search/BMKGeocodeSearch.h>*/
@property (nonatomic, strong)BMKGeoCodeSearch *geoSearch;
/**搜索输入框*/
@property (nonatomic, strong)UITextField *textF;
@property (nonatomic, strong)UITableView *tab;
@property (nonatomic, strong)NSArray *results;
@end

@implementation BaiduMapViewController
- (void)viewWillAppear:(BOO
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值