集成百度地图浅析

自己整了一下百度地图,但是只是刚刚开始,还有好多没用用到。

1.首先用cocoapods导入百度地图的包,然后运行报了好多错误,是因为官网说要改成Objective-C++,但是我改了以后出现好多错误,百度问题说是要改成Objective-C,错误消失。


2.要在info.plist 文件中配置

这个display name 我就写的我项目名称。


还有iOS9以后改成了https,要加上上面画线的部分

我只用了定位功能,一开始死活定位不出,原来忘记写了[_locServicestartUserLocationService];这一句,原谅我是个小菜鸟。

- (void)didUpdateBMKUserLocation:(BMKUserLocation*)userLocation

{

NSLog(@"当前位置%f,%f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);

_mapView.showsUserLocation=YES;

[_mapViewupdateLocationData:userLocation];

CLLocationCoordinate2Dcoord;

coord.latitude=userLocation.location.coordinate.latitude;

coord.longitude=userLocation.location.coordinate.longitude;

////添加大头针

//BMKPointAnnotation *ann=[[BMKPointAnnotation alloc] init];

//ann.coordinate=coord;

//ann.title=@"你好";

//ann.subtitle=@"我是大头针,我的头很大";

//[_mapView addAnnotation:ann];

BMKCoordinateRegionregion ;//表示范围的结构体

region.center= coord;//指定地图中心点

//region.span.latitudeDelta = 0.1;//经度范围(设置为0.1表示显示范围为0.2的纬度范围)

//region.span.longitudeDelta = 0.1;//纬度范围

[_mapViewsetRegion:regionanimated:YES];

}

实现协议的方法,就可以实现自己位置的定位。

我也是刚刚开始搞地图,有不对的地方欢迎指正!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容