User's Location as Point of Origin
iOS v4
Often you may want to get directions starting from a user's actual current position, instead of from another fixed Location. The following code snippet gives an example on how to implement this.
First, initialize a PositionProvider
, which can be used with MPDirectionsQuery
to achieve the desired result.
In order to use the PositionProvider
to extract a MPPoint
, you need to use mapControl?.positionProvider?.latestPosition?.coordinate
. This will allow you to make a MPPoint, using the coordinates from the positionProvider
.
Further details on how user positioning works, and how to display it, can be found here.
This results in directions queries originating from the user's current location.
Last updated