User's Location as Point of Origin
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.
val directionsService = MPDirectionsService(mContext)
//Create an Origin MPPoint with the users latitude, longitude and Z-index. If no Z-index is available just use 0.0
val origin = MPPoint(userLatitude, userLongitude, userZIndex)
val destination = destinationLocation.getPoint()
directionsService.setRouteResultListener { route, error ->
//Handle the route result here
}
directionsService.query(origin, destination)Last updated
Was this helpful?