您的位置:首页 > 大数据 > 人工智能

baidumap demo(三)

2014-02-14 16:05 141 查看

定位

您可以通过以下代码来开启定位功能:

源码复制打印关于

//开启定位功能

[_mapView setShowsUserLocation:YES];

定位成功后,可以通过mapView.userLocation来获取位置数据。

您也可以通过以下代码来使用定位三态效果,包括普通态、跟随态和罗盘态:

源码复制打印关于

//普通态

-(IBAction)startLocation:(id)sender

{

NSLog(@"进入普通定位态");

_mapView.showsUserLocation = NO;//先关闭显示的定位图层

_mapView.userTrackingMode = BMKUserTrackingModeNone;//设置定位的状态

_mapView.showsUserLocation = YES;//显示定位图层

}

//跟随态

-(IBAction)startFollowing:(id)sender

{

NSLog(@"进入跟随态");

_mapView.showsUserLocation = NO;

_mapView.userTrackingMode = BMKUserTrackingModeFollow;

_mapView.showsUserLocation = YES;

}

//罗盘态

-(IBAction)startFollowHeading:(id)sender

{

NSLog(@"进入罗盘态");

_mapView.showsUserLocation = NO;

_mapView.userTrackingMode = BMKUserTrackingModeFollowWithHeading;

_mapView.showsUserLocation = YES;

}

完整的示例代码请参考相关下载demo工程中的LocationDemoViewController.mm文件

示例效果如下:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: