在蓝色脉动点(用户当前位置)上显示航向,而不会丢失精度圆
我有一个 CLLocation 管理器,如下所示
myLocation = [[CLLocationManager alloc] init];
myLocation.desiredAccuracy = kCLLocationAccuracyBestForNavigation ;
myLocation.delegate=self;
,如果设备支持标题信息,则调用方法来更新标题
if([CLLocationManager headingAvailable])
[myLocation startUpdatingHeading];
,并从以下方法检索标题更改,
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
[mymap setTransform:CGAffineTransformMakeRotation(-1 * newHeading.trueHeading * 3.14159 / 180)];
}
我可以使用此信息(newHeading.trueHeading)来旋转地图。但是,我如何在蓝点(用户当前位置的指示器)上显示一个以给定或强制精度描绘前进方向的扇区。我可以使用蓝点的自定义图像,但它会失去光“精度圈”。有什么方法可以获取蓝点视图的引用并修改它,这样精度圆就不会丢失。
此外,可以通过负旋转来避免注释的旋转,但是当地图旋转时,注释的“标题”和“副标题”会延伸到可见屏幕的视图之外。有什么办法可以将它们限制在地图视图中吗?
感谢您提前提供的任何帮助
I have a CLLocation manager as follows
myLocation = [[CLLocationManager alloc] init];
myLocation.desiredAccuracy = kCLLocationAccuracyBestForNavigation ;
myLocation.delegate=self;
if device supports heading information then method is called to update heading
if([CLLocationManager headingAvailable])
[myLocation startUpdatingHeading];
and change in heading are retrieved from following method
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
[mymap setTransform:CGAffineTransformMakeRotation(-1 * newHeading.trueHeading * 3.14159 / 180)];
}
I can use this information (newHeading.trueHeading) to rotate the map. But how can I show a sector that will depict heading direction with given or forced accuracy, on blue dot (indicator of users current location). I am able to use custom image for blue dot but it looses light "accuracy circle" then. Is there any way to get a reference to the blue dot view and modify it, so that accuracy circle is not lost.
Also rotation of annotations can be avoided with negative rotation but when map is rotating the "Title" and "subTitle" of annotations gets extended beyond view of visible screen. Is there any way to limit them to map's view.
Thanks for any help in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用此项目作为指南。它会旋转整个地图视图,但您可以将其推断到您的视图。
编辑:如果您想自定义 userLocation 注释,您必须实现 viewForAnnotation 并检查给定注释是否为
MKUserLocation
并返回根据需要配置的自定义注释视图。You can use this project as a guide. It rotates the whole mapView, but you can extrapolate it to your view.
EDIT: If you want to customize the userLocation annotation you have to implement viewForAnnotation and check if the given annotation is
MKUserLocation
and return a custom annotationView configured as you want.