bmkmac single user modetrackingmode怎么用

后使用快捷导航没有帐号?
暂时没有人问过相似的问题,你可以做第一个提问题的人
查看: 2737|回复: 15
BMKUserTrackingModeNone
BMKUserTrackingModeNone 是圆点 怎么跟踪方向?&&
哪有有实现过的 给个思路 难道是强制改变定位图标计自己算方向么???
你是不是指定位的三态? 看一下demo 中关于定位的那个部分&&
你是不是指定位的三态? 看一下demo 中关于定位的那个部分
demo里面得定位 只有BMKUserTrackingModeFollow才显示箭头。
BMKUserTrackingModeNone 显示的是小蓝点
你是不是指定位的三态? 看一下demo 中关于定位的那个部分
[url=]络[/url]
(160.92 KB, 下载次数: 0)
10:22 上传
(162.25 KB, 下载次数: 0)
10:22 上传
那个三角号实际上就是一个三角号的图片&&不是说从圆形变过来的
这个就是需要你自己准备好一个定位用的三角号的图片&&然后在定位图层上用&&方向这个是有一个参数传进去的&&
那个三角号实际上就是一个三角号的图片&&不是说从圆形变过来的
这个就是需要你自己准备好一个定位用的三 ...
你好,如果替换圆形图片为自定义的三角号图片后,如何控制三角号的方向啊?
BMKUserLocation类 参考
CLHeading * & & & & heading
本帖最后由 we... 于
16:58 编辑
BMKUserLocation类 参考
CLHeading *& && && &heading
你好。在拖动地图之后,- (void)didUpdateUserHeading: (BMKUserLocation *)userLocation
中更新用户位置信息, [_mapView updateLocationData:userLocation];
只更新了经纬度,而heading信息没有更新。
请问,此时定位用户的方向为什么没有起作用啊?
PS:在不拖动地图的时候,方向更新是起作用的。关键是在拖动地图之后,方向就没有效果了。求助。谢谢
PS2:这个问题以前也有人碰到过,都是拖动地图后发生的。
PS3:目前单纯替换蓝色圆点图标,不能解决“拖动地图后方向更新的问题”。
跪求重视!!!谢谢。
那个三角号实际上就是一个三角号的图片&&不是说从圆形变过来的
这个就是需要你自己准备好一个定位用的三 ...
- (void)updateLocationViewWithParam:(BMKLocationViewDisplayParam*)locationViewDisplayP只能改图标&&不能改旋转角度
那个定位的图层好像SDK里面没有API能直接获取到
最后我搜索了所有的子图层 找到个LocationView的类 在 didUpdateUserHeading 更新下更新方向不太对&&老是会闪烁 旋转角度变成0 应该有别的地方也改了旋转角度的 求设置方向的接口
那个三角号实际上就是一个三角号的图片&&不是说从圆形变过来的
这个就是需要你自己准备好一个定位用的三 ...
试了下&&地图整体旋转的时候 好像问题更多,应该有别的接口设置定位图标旋转的
不能用UIView transfrom
那个三角号实际上就是一个三角号的图片&&不是说从圆形变过来的
这个就是需要你自己准备好一个定位用的三 ...
额 问题解决了
在onDrawMapFrame也设置下定位图层的旋转角度就好了,不会再闪烁了
设置旋转角度的时候 要减去BMKMapView自身的旋转角度&&就和最终模式没有几毛钱区别了
额 问题解决了
在onDrawMapFrame也设置下定位图层的旋转角度就好了,不会再闪烁了
设置旋转角度的时候 要 ...
请问你具体怎么解决的
额 问题解决了
在onDrawMapFrame也设置下定位图层的旋转角度就好了,不会再闪烁了
设置旋转角度的时候 要 ...
求解决方法..谢谢 我也卡在这里了
我也在写这个呢 弄了两天了 求解决方法&&
同求,我的小箭头不能随着方向摆动
你好。在拖动地图之后,- (void)didUpdateUserHeading: (BMKUserLocation *)userLocation
中更新用户位 ...
你好!我也遇到这个问题了 请问有没有解决的办法 跪求!!
Powered byios百度地图的使用
在这里就不在介绍百度的具体配置,配置详见/map/index.php?title=iossdk
1.首先接受基本的地图功能
新建一个地图类,xib拖也行,我这边是代码实现的。
_mapView = [[BMKMapView alloc]initWithFrame:CGRectMake(0, 0,self.view.frame.size.width, self.view.frame.size.height)];
[self.view addSubview:_mapView];
#pragma mark - 设置mapView属性
-(void)setMapViewProperty
_mapView.mapType = BMKUserTrackingModeFollowWithH
_mapView.showsUserLocation = YES;
_mapView.zoomLevel = 16;
_mapView.rotateEnabled = NO;
passLocationValue];
#pragma mark -传入定位坐标 (必须打开程序时已经获取到地理位置坐标,为了解决地图定位时总是先显示天安门)
-(void)passLocationValue
BMKCoordinateRegion viewRegion = BMKCoordinateRegionMake([UserLocationManager sharedInstance].clloction.coordinate, BMKCoordinateSpanMake(0.02f,0.02f));
BMKCoordinateRegion adjustedRegion = [_mapView regionThatFits:viewRegion];
[_mapView setRegion:adjustedRegion animated:YES];
#pragma mark -设置定位圆点属性
-(void)setUserImage
BMKLocationViewDisplayParam* param = [[BMKLocationViewDisplayParam alloc] init];
param.locationViewOffsetY = 0;
param.locationViewOffsetX = 0;
param.isAccuracyCircleShow =NO;
param.isRotateAngleValid = NO;
[_mapView updateLocationViewWithParam:param];
实现BMKMapViewDelegate,以下是mapView的一些协议方法
*地图区域即将改变时会调用此接口
*@param mapview 地图View
*@param animated 是否动画
- (void)mapView:(BMKMapView *)mapView regionWillChangeAnimated:(BOOL)animated
*地图区域改变完成后会调用此接口
*@param mapview 地图View
*@param animated 是否动画
- (void)mapView:(BMKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
*地图状态改变完成后会调用此接口
*@param mapview 地图View
- (void)mapStatusDidChanged:(BMKMapView *)mapView
这样基本的地图界面就出来了
2.地图定位
我这边是将定位封装了一个独立的manager类来管理定位和地图上滑动到的位置
#import &UserLocationManager.h&
#import &BMKGeocodeSearch.h&
@implementation UserLocationManager
+ (UserLocationManager *)sharedInstance
static UserLocationManager *_instance =
@synchronized (self) {
if (_instance == nil) {
_instance = [[self alloc] init];
if (self == [super init])
//[self getBMKUserLocation];
//[self initGeoCodeSearch];
#pragma 初始化百度地图用户位置管理类
初始化百度地图用户位置管理类
- (void)initBMKUserL
_locService = [[BMKLocationService alloc]init];
_locService.delegate =
[self startLocation];
#pragma 打开定位服务
打开定位服务
-(void)startLocation
[_locService startUserLocationService];
#pragma 关闭定位服务
关闭定位服务
-(void)stopLocation
[_locService stopUserLocationService];
#pragma BMKLocationServiceDelegate
*用户位置更新后,会调用此函数
*@param userLocation 新的用户位置
- (void)didUpdateUserLocation:(BMKUserLocation *)userLocation
cllocation = userLocation.
_clloction =
_userLatitude = cllocation.coordinate.
_userLongitude = cllocation.coordinate.
[self stopLocation];
[self initGeoCodeSearch];
*在停止定位后,会调用此函数
- (void)didStopLocatingUser
[_mapViewVC setMapViewProperty];
*定位失败后,会调用此函数
*@param error 错误号
- (void)didFailToLocateUserWithError:(NSError *)error
[self stopLocation];
#pragma BMKGeoCodeSearchDelegate
-(void)initGeoCodeSearch
_geoCodeSearch = [[BMKGeoCodeSearch alloc]init];
_geoCodeSearch.delegate =
BMKReverseGeoCodeOption *reverseGeoCodeOption= [[BMKReverseGeoCodeOption alloc] init];
reverseGeoCodeOption.reverseGeoPoint = cllocation.
[_geoCodeSearch reverseGeoCode:reverseGeoCodeOption];
*返回反地理编码搜索结果
*@param searcher 搜索对象
*@param result 搜索结果
*@param error 错误号,@see BMKSearchErrorCode
-(void) onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
if (error == 0)
_cityName = result.addressDetail.
NSLog(@&%@&,_cityName);
您可能也会对以下文章感兴趣
QQ : 341470
Friend Link
New MemberiOS 问题:iOS使用百度地图定位时不显示北京的地图直接定位 ,要怎么做,求大神指教啊!!! -
iOS使用百度地图定位时不显示北京的地图直接定位 ,要怎么做,求大神指教啊!!!
共有 5 个回答
BMKLocationService *aa = [[BMKLocationService alloc]init];
self.locationService =
self.locationService.delegate =
//启动LocationService
[self.locationService startUserLocationService];
[self.myBadiduMapView setShowsUserLocatio
登录后方可回复
没有用!还是会先出现北京的地图。
登录后方可回复
这个问题我也遇到过,先把他隐藏起来,等定位成功了再让他显示出来,之前的那一段空白就自己想办法了
登录后方可回复
延迟加载页面应该可以。
登录后方可回复
[_locationService startUserLocationService];
_mapView.showsUserLocation = YES;
_mapView.userTrackingMode = BMKUserTrackingModeN
_mapView.showsUserLocation = YES;
登录后方可回复
登录后方可回答ios百度地图的使用(普通定位、反地理编码)-IOS开发-源码库|专注为中国站长提供免费商业网站源码下载!
当前位置:----ios百度地图的使用(普通定位、反地理编码)
ios百度地图的使用(普通定位、反地理编码)
iOS定位 - 普通定位(没有地图) - 反地理编码(得到具体位置)使用代码如何实现呢,下面小编就给大家详解ios百度地图的使用(普通定位、反地理编码,有需要的朋友可以参考下
iOS定位 - 普通定位(没有地图) - 反地理编码(得到具体位置),下面通过代码给大家详解,代码如下:
#import &CoreLocation/CoreLocation.h& 使用到的头文件 要引入CoreLocation这个包
&CLLocationManagerDelegate&
使用的代理名称
//1.使用定位服务
//设置app有访问定位服务的权限
//在使用应用期间 / 始终(app在后台)
//info.plist文件添加以下两条(或者其中一条):
//NSLocationWhenInUseUsageDescription 在使用应用期间
//NSLocationAlwaysUsageDescription 始终
//2.LocationManager 对象管理相关的定位服务
_manager = [[CLLocationManager alloc] init];
//manager判断: 手机是否开启定位 / app是否有访问定位的权限
//[CLLocationManager locationServicesEnabled]; //手机是否开启定位
//[CLLocationManager authorizationStatus]; //app访问定位的权限的状态
if (![CLLocationManager locationServicesEnabled] || [CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorizedWhenInUse) {
[_manager requestWhenInUseAuthorization]; //向用户请求访问定位服务的权限
_manager.delegate =
_manager.desiredAccuracy = kCLLocationAccuracyB
_manager.distanceFilter = 1.0f;
[_manager startUpdatingLocation];
//定位代理经纬度回调
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
[_manager stopUpdatingLocation];
CLGeocoder * geoCoder = [[CLGeocoder alloc] init];
[geoCoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) {
for (CLPlacemark * placemark in placemarks) {
NSDictionary *test = [placemark addressDictionary];
// Country(国家) State(城市) SubLocality(区) Name全称
NSLog(@&%@&, [test objectForKey:@&Name&]);
ios百度地图的使用(普通定位、反地理编码)
1.首先接受基本的地图功能
新建一个地图类,xib拖也行,我这边是代码实现的。
_mapView = [[BMKMapView alloc]initWithFrame:CGRectMake(0, 0,self.view.frame.size.width, self.view.frame.size.height)];//添加mapVIew
[self.view addSubview:_mapView];
#pragma mark - 设置mapView属性
-(void)setMapViewProperty
_mapView.mapType = BMKUserTrackingModeFollowWithH
_mapView.showsUserLocation = YES; //是否显示定位图层(即我的位置的小圆点)
_mapView.zoomLevel = 16;//地图显示比例
_mapView.rotateEnabled = NO; //设置是否可以旋转
[self passLocationValue];
#pragma mark -传入定位坐标
//设置定位到得用户的位置,这里是简单的应用方法(必须打开程序时已经获取到地理位置坐标,为了解决地图定位时总是先显示天安门)
-(void)passLocationValue
BMKCoordinateRegion viewRegion = BMKCoordinateRegionMake([UserLocationManager sharedInstance].clloction.coordinate, BMKCoordinateSpanMake(0.02f,0.02f));
BMKCoordinateRegion adjustedRegion = [_mapView regionThatFits:viewRegion];
[_mapView setRegion:adjustedRegion animated:YES];
#pragma mark -设置定位圆点属性
-(void)setUserImage
//用户位置类
BMKLocationViewDisplayParam* param = [[BMKLocationViewDisplayParam alloc] init];
param.locationViewOffsetY = 0;//偏移量
param.locationViewOffsetX = 0;
param.isAccuracyCircleShow =NO;//设置是否显示定位的那个精度圈
param.isRotateAngleValid = NO;
[_mapView updateLocationViewWithParam:param];
这样基本的地图界面就出来了
如果你需要在地图上做一些请求,可以实现BMKMapViewDelegate,以下是mapView的一些协议方法
*地图区域即将改变时会调用此接口
*@param mapview 地图View
*@param animated 是否动画
- (void)mapView:(BMKMapView *)mapView regionWillChangeAnimated:(BOOL)animated
*地图区域改变完成后会调用此接口
*@param mapview 地图View
*@param animated 是否动画
- (void)mapView:(BMKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
*地图状态改变完成后会调用此接口
*@param mapview 地图View
- (void)mapStatusDidChanged:(BMKMapView *)mapView
2.地图定位
我这边是将定位封装了一个独立的manager类来管理定位和地图上滑动到的位置,是将定位功能和地图mapVIew独立开来,管理地理移动位置的变化
#import &Foundation/Foundation.h&
#import &BMapKit.h&
@interface UserLocationManager : NSObject &BMKMapViewDelegate,BMKLocationServiceDelegate&
CLLocation *
BMKReverseGeoCodeOption *reverseGeoCodeO//逆地理编码
@property (strong,nonatomic) BMKLocationService *locS
@property (strong,nonatomic) NSString *cityN
//用户纬度
@property (nonatomic,assign) double userL
//用户经度
@property (nonatomic,assign) double userL
//用户位置
@property (strong,nonatomic) CLLocation *
//初始化单例
+ (UserLocationManager *)sharedI
//初始化百度地图用户位置管理类
- (void)initBMKUserL
//开始定位
-(void)startL
//停止定位
-(void)stopL
#import &UserLocationManager.h&
@implementation UserLocationManager
+ (UserLocationManager *)sharedInstance
static UserLocationManager *_instance =
@synchronized (self) {
if (_instance == nil) {
_instance = [[self alloc] init];
if (self == [super init])
[self initBMKUserLocation];
#pragma 初始化百度地图用户位置管理类
* 初始化百度地图用户位置管理类
- (void)initBMKUserLocation
_locService = [[BMKLocationService alloc]init];
_locService.delegate =
[self startLocation];
#pragma 打开定位服务
* 打开定位服务
-(void)startLocation
[_locService startUserLocationService];
#pragma 关闭定位服务
* 关闭定位服务
-(void)stopLocation
[_locService stopUserLocationService];
#pragma BMKLocationServiceDelegate
*用户位置更新后,会调用此函数
*@param userLocation 新的用户位置
- (void)didUpdateUserLocation:(BMKUserLocation *)userLocation
cllocation = userLocation.
_clloction =
_userLatitude = cllocation.coordinate.
_userLongitude = cllocation.coordinate.
[self stopLocation];(如果需要实时定位不用停止定位服务)
*在停止定位后,会调用此函数
- (void)didStopLocatingUser
*定位失败后,会调用此函数
*@param error 错误号
- (void)didFailToLocateUserWithError:(NSError *)error
[self stopLocation];
以上代码就是本文ios百度地图的使用(普通定位、反地理编码),希望对大家今后的工作和学习有所帮助。
注:相关教程知识阅读请移步到频道。
相关IOS开发:
IOS开发搜索
IOS开发推荐
热门源码推荐
热门IOS开发
©2012ios5 - Setting MKUserTrackingModeFollowWithHeading - Stack Overflow
to customize your list.
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
Join the Stack Overflow community to:
Ask programming questions
Answer and help your peers
Get recognized for your expertise
I tried to set the user tracking mode in the viewDidLoad method (and in viewWillAppear). If I set it to MKUserTrackingModeFollowWithHeading (value of 2), it does not take effect. Actually, right after setting its value to 2, if I print it value, it is 1, why? I have never seen such a thing in any programming experience!
Here is how I set it:
[self.mapView setUserTrackingMode: MKUserTrackingModeFollowWithHeading
animated: YES];
If I do the same in the viewWillAppear method, the effect is the same. However, the second time this view is displayed, the setting will take effect. (I have a tab viewcontroller, I switch the view to another and then switch back).
The way I see it does not take effect is two measures: (1) print its value right after setting it (2) in the map view, the heading is not displayed.
What the is going on?
42.2k15103202
I know this is a really old post, but just in case it helps others out there looking for a solution, the reason is because you need to set the userTrackingMode after the map has loaded.
So set your class as the delegate, then add this delegate method:
- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView {
mapView.userTrackingMode = MKUserTrackingModeFollowWithH
I also have the same issue. Cannot find any information in the map header about it not working, or working for that matter.
The solution I've implemented is to use a custom CLLocationManager to retrieve the heading, and then rotate the map appropriately. See this answer for some help using this method:
Also note that the iOS simulator doesn't currently allow for heading simulation.
Could it be that it is being called too early? try putting the setUserTrackingMode call in the viewDidAppear method, and make sure you haven't set a different value in Interface Builder (the gui part of Xcode)
5,76032251
I was having this problem as well. Even though I had already set showsUserLocation to YES and userTrackingMode to MKUserTrackingModeFollowWithHeading in -viewDidLoad, the heading still was only being displayed every once in a while.
After checking 'Shows User Location' in the nib for good measure, as well as moving the setUserTrackingMode: to -viewDidAppear, it started consistently showing the heading. I would say that -viewDidLoad is called too early for the mapView. Not sure why, though.
So the reason why this error occurs:
UIMapView is not loaded yet in the viewDidLoad.
Putting the code in the methode mapViewDidFinishLoadingMap is also not a good idea because it's not said that method will be called. The method is not called when tiles are cached (for example if you have another mapview in you app on a different place zoomed to the same tiles).
So it's not a good idea to put it in the mapViewDidFinishLoadingMap either.
Final solution:
Create a private boolean and set it to false in the viewDidLoad
BOOL _didFollowUserA
Set the mapview delegate to self and add this method:
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
if(!_didFollowUserAlready)
_didFollowUserAlready = TRUE;
[mapView setUserTrackingMode:MKUserTrackingModeFollow animated:TRUE];
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled

我要回帖

更多关于 single user mode 的文章

 

随机推荐