简体   繁体   English

在Mapbox(iOS)上将方向箭头添加到当前位置

[英]Adding direction arrow to current location on Mapbox (iOS)

I have an app that uses Mapbox to present a map with the user location, it looks like this: 我有一个使用Mapbox呈现带有用户位置的地图的应用程序,它看起来像这样:

Mapbox

I want to add a direction arrow to the current location marker that shows you the direction you're walking to, like that: 我想在当前位置标记处添加方向箭头,向您显示您要前往的方向,如下所示:

带箭头

Does anybody know how can I add this arrow using Mapbox iOS SDK ? 有谁知道如何使用Mapbox iOS SDK添加此箭头?

Thanks! 谢谢!

With Mapbox Maps SDK for iOS v3.6.3 or newer it's possible to add an always-on heading indicator using MGLMapView.showsUserHeadingIndicator . 使用Mapbox Maps SDK for iOS v3.6.3或更高版本,可以使用MGLMapView.showsUserHeadingIndicator添加始终开启的标题指示器。 With this setting enabled, the user location annotation will look like this: 启用此设置后,用户位置注释将如下所示:

抚摸箭头

Also see this example for how to implement this in a custom user location annotation. 另请参阅此示例 ,了解如何在自定义用户位置注释中实现此功能。

Old answer below, for posterity. 对于后代,下面的旧答案。


Custom user location annotation views are a feature of the upcoming v3.4.0 release, which you can try out now in pre-release . 自定义用户位置注释视图是即将发布的v3.4.0版本的一项功能,您可以在预发布版中立即尝试。

You may find the SDK's default implementation of MGLUserLocationAnnotationView , MGLFaux3DUserLocationAnnotationView , useful in constructing your own. 您可以找到SDK的MGLUserLocationAnnotationView的默认实现, MGLFaux3DUserLocationAnnotationView ,可用于构建您自己的实现。

As for adding an always-on heading indicator, that's not yet possible with MGLMapView 's location manager — for now, you will need to get the heading from your own location manager when the tracking mode is not .FollowWithHeading . 至于添加一个永远在线的标题指示器,这是MGLMapView的位置管理器尚不可能的 - 现在,当跟踪模式不是.FollowWithHeading时,您需要从您自己的位置管理器获取标题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM