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文件
示例效果如下:
相关文章推荐
- baidumap demo(二)
- baidumap demo(一)
- iis HTTP Error 503. The service is unavailable.
- waiting for network configuration
- tair缓存系统实现
- load fallback graphics devices [fail]
- PAINTSTRUCT结构
- underscore中的find,map,each,sortBy,filter,chain的用法
- Hdu 2473 Junk-Mail Filter (并查集的删除)
- 错误:UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode的解决方案
- golang waitgroup 及 sync.Once 示例
- 技术博客已经搬家到blog.tbai.me
- ksvcreate: Process creation failed
- Aircrack-ng官方文档翻译[中英对照]---Airmon-ng
- communicationn failure问题(ext异步访问中)
- 利用FMX控件的MakeScreenshot过程实现WAIT效果
- mount to NFS server 'p470-1' failed: RPC Error: Program not registered
- POJ 3007 Organize Your Train part II(哈希链地址法)
- but failed to unregister it when the web .....
- baiduMap试手《办理进京证和市区警察查询进京证的地址浏览》