Adding direction arrow to current location on Mapbox (iOS)

試著忘記壹切 提交于 2019-12-10 14:47:50

问题


I have an app that uses Mapbox to present a map with the user location, it looks like this:

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?

Thanks!


回答1:


With Mapbox Maps SDK for iOS v3.6.3 or newer it’s possible to add an always-on heading indicator using 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.

You may find the SDK’s default implementation of MGLUserLocationAnnotationView, MGLFaux3DUserLocationAnnotationView, useful in constructing your own.

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.



来源:https://stackoverflow.com/questions/40279217/adding-direction-arrow-to-current-location-on-mapbox-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!