高德地图改变当前位置_高德地图当前位置图标旋转功能实现
实现思路
1、添加高德地图
- (void)creatMapView {
_mapView = [[MAMapView alloc]initWithFrame:self.view.bounds];
_mapView.delegate = self;
_mapView.showsCompass = NO;
_mapView.showsUserLocation = YES;
_mapView.userTrackingMode = MAUserTrackingModeFollow;
//是否自定义用户位置精度圈
_mapView.customizeUserLocationAccuracyCircleRepresentation = YES;
[self.view addSubview:_mapView];
}
2、实现地图添加大头针的代理,设置当前位置图标
- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id)annotation {
//用户当前位置大头针
if ([annotation isKindOfClass:[MAUserLocation class]])
{
static NSString *kUserLocationStyleReuseIndetifier = @"userLocationStyleReuseIndetifier";
MAAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:kUserLocationStyleReuseIndetifier];
if (annotationView == nil)
{
annotationView = [[MAAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:kUserLocationStyleReuseIndetifier];
}
annotationView.canShowCallout = NO;
annotationView.image = [UIImage imageNamed:@"heardImg_passenger_default"];
annotationView.frame = CGRectMake(0, 0, 26, 26);
annotationView.contentMode = UIViewContentModeScaleToFill;
annotationView.layer.masksToBounds = YES;
annotationView.tag = kUserHearderAnnotaionViewTag;
return annotationView;
}
//其他大头针
else if ([annotation isKindOfClass:[MAPointAnnotation class]]) {
}
return nil;
}
3、在地图时时位置更新的方法里实现旋转功能
- (void)mapView:(MAMapView *)mapView didUpdateUserLocation:(MAUserLocation *)userLocation updatingLocation:(BOOL)updatingLocation
{
NSLog(@"%f,%f,%f",userLocation.heading.x,userLocation.heading.y,userLocation.heading.z);
MAAnnotationView *hearderAnnotationView = [self.mapView viewWithTag:kUserHearderAnnotaionViewTag];
if (hearderAnnotationView)
{
hearderAnnotationView.transform = CGAffineTransformIdentity;
CGAffineTransform transform = CGAffineTransformMakeRotation(-M_PI*userLocation.heading.magneticHeading/180.0);
hearderAnnotationView.transform = transform;
}
}
全部代码如下
#import "ViewController.h"
#import
#import
static const NSUInteger kUserHearderAnnotaionViewTag = 10000;
@interface ViewController ()
@property (nonatomic, strong) MAMapView *mapView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self creatMapView];
}
- (void)creatMapView {
_mapView = [[MAMapView alloc]initWithFrame:self.view.bounds];
_mapView.delegate = self;
_mapView.showsCompass = NO;
_mapView.showsUserLocation = YES;
_mapView.userTrackingMode = MAUserTrackingModeFollow;
//是否自定义用户位置精度圈
_mapView.customizeUserLocationAccuracyCircleRepresentation = YES;
[self.view addSubview:_mapView];
}
#pragma mark MAMapViewDelegate
- (void)mapView:(MAMapView *)mapView didUpdateUserLocation:(MAUserLocation *)userLocation updatingLocation:(BOOL)updatingLocation
{
NSLog(@"%f,%f,%f",userLocation.heading.x,userLocation.heading.y,userLocation.heading.z);
//通过hearderAnnotationView的tag值拿到当前位置的annotationView
MAAnnotationView *hearderAnnotationView = [self.mapView viewWithTag:kUserHearderAnnotaionViewTag];
if (hearderAnnotationView)
{
hearderAnnotationView.transform = CGAffineTransformIdentity;
CGAffineTransform transform = CGAffineTransformMakeRotation(-M_PI*userLocation.heading.magneticHeading/180.0);
hearderAnnotationView.transform = transform;
}
}
- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id)annotation {
//用户当前位置大头针
if ([annotation isKindOfClass:[MAUserLocation class]])
{
static NSString *kUserLocationStyleReuseIndetifier = @"userLocationStyleReuseIndetifier";
MAAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:kUserLocationStyleReuseIndetifier];
if (annotationView == nil)
{
annotationView = [[MAAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:kUserLocationStyleReuseIndetifier];
}
annotationView.canShowCallout = NO;
annotationView.image = [UIImage imageNamed:@"heardImg_passenger_default"];
annotationView.frame = CGRectMake(0, 0, 26, 26);
annotationView.contentMode = UIViewContentModeScaleToFill;
annotationView.layer.masksToBounds = YES;
//设置当前位置大头针annotationView的tag值
annotationView.tag = kUserHearderAnnotaionViewTag;
return annotationView;
}
//其他大头针
else if ([annotation isKindOfClass:[MAPointAnnotation class]]) {
}
return nil;
}
@end
最后
高德地图改变当前位置_高德地图当前位置图标旋转功能实现相关推荐
- android定位附近店铺,高德地图怎么添加店铺位置_高德地图定位怎么设置添加自己家店铺位置_攻略...
高德地图是国内最知名的地图导航软件,基本上每个人的手机上都有这款软件.如今想要方便出行都可以通过高得地图查询位置就可以了,给我们的生活带来了很多的便利.在高德地图上也可以很方便的查询各个地方的店铺,通 ...
- android 高德地图移动卡顿_高德地图4.8和百度地图3.1的抉择,如何发送地址到车机(下载失效本帖奉上百度云盘)...
9月已经过去半个月了,升级一直围绕着领克车友,8月的兴奋,总想知道车机有什么改变,很多车友提前去预约,总想尝第一口鲜,这个第一口可不好喝,头啖汤随好,但会烫口,于是我带着观望的态度,因为我始终觉得,安 ...
- android 高德地图移动卡顿_高德、百度和腾讯三家比拼,哪个 Android 车机地图 App 更好用?...
写在前面 不管是自己开车.还是平时打车,相信你一定留意过驾驶座旁边位于车辆中间的那块大屏幕,不管是平时开车导航.放音乐,还是通过倒车影像辅助倒车,都离不开这块屏幕,这就是中控车机. 中控车机往往搭载的 ...
- 6个座位办公室最佳位置_办公室座位最佳位置(讲解)
在办公室选择办公位置也很重要,办公位置的好坏也会直接影响工作效率和进度,从而影响到个人健康以及公司的财运等问题. 所以办公室座位不得不重视,下面大师为大家讲解关于办公室位置最佳位置. 办公室座位最佳位 ...
- 唱歌如何保持高位置_什么是高位置发声?
高位置是正确歌唱发音的一种声音效果,是各个发声器官.歌唱机能有机配合.协调运动.整体发音的一种感觉.从视觉和触觉而论,是看不见.摸不着的,具有抽象性:从听觉来说,声音却又是具体的,因为声音是由听觉感受 ...
- 安卓开发 高德地图 marker 点击移动位置_高德手机AR导航再升级,有惊喜
高德地图发布V10.70新版本啦AR驾车导航服务再次升级 支持连接车内行车记录仪! 由行车记录仪的摄像头充当"眼睛",实时捕捉现实道路画面,再通过手机地图呈现直观的3D导航指引,为 ...
- 安卓开发 高德地图 marker 点击移动位置_高德地图AR导航功能上线 ~
作者:小A Date:2020-08-20 来源:AIRX社区微信公众号 高德地图近期发布新版本10.60,上线AR导航功能,目前该功能可以在部分安卓手机上可以体验到.AR技术能将虚拟与现实联通,从视 ...
- 高德地图去掉定位按钮_高德地图自定义定位按钮及点击事件
最近使用了一下高德地图,使用期间将出现的问题记录一下.文中出现不对的地方,悉听各路大神指正.2018年11月23日15:59:46 1.首先我们初始化map控制对象aMap .if (aMap ==n ...
- 高德地图如何取消订单_高德地图怎么取消订单
大家好,我是时间财富网智能客服时间君,上述问题将由我为大家进行解答. 高德地图取消订单的方法是: 1.进入到地图页面之后选择点击页面右上角的头像进入到个人中心页面: 2.打开之后往下滑,找到我的: 3 ...
- 高德地图的标志放大_高德地图点标注的分布与缩放
本文介绍了在 React Native 平板开发中使用高德地图组件的一个案例,重点介绍了如何计算并缩放到所需状态,以及地图 Webview 与 React Native 通信的方式. 欢迎关注我的专栏 ...
最新文章
- python django 的启动脚本
- docker oracle navicat_拥抱开源从零开始 Docker、Mysql amp; JPA
- ehcache缓存原理_贼厉害,手撸的 SpringBoot缓存系统,性能杠杠的!
- SQL Server 自定义快捷键
- linux文件系统及bash基础特性
- java 装配_Spring 通过Java代码装配bean
- 复制中文到linux系统,怎么是的window文字复制到linux下
- 凝血超声手术室行业调研报告 - 市场现状分析与发展前景预测
- c语言中的钩子函数,生命周期(vue的钩子函数)
- c语言so文件反编译,apk so文件反编译教程
- 使用openwrt-SDK 生成IPK
- 控制面板中没有reltek高清晰音频管理器 插入耳机后仍然外放(已解决)
- 服务器重启后samba启动不了,提示stop: Unknown instance: smbd start/running, process 76585...
- MTK Kernel Log 看电池信息
- 什么叫最少拍计算机控制系统,最少拍无波纹计算机控制系统的一种综合方法.doc...
- win7 查看php版本信息,window_Windows系统版本怎么看?2种查看windows版本的方法介绍,前段时间微软正式开始向Win7和 - phpStudy...
- 回归分析regression analysis
- Linux || 查询类命令
- Android实现 制作隐藏图片效果 (幻影坦克)
- 基于C#+SQLServer开发的餐饮管理系统源码