简体   繁体   中英

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

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!

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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