public static class MapboxDirections.Builder<T extends MapboxDirections.Builder> extends MapboxBuilder
baseUrl, clientAppName
Constructor and Description |
---|
Builder()
Constructor
|
Modifier and Type | Method and Description |
---|---|
Boolean |
allowsRoundaboutExits() |
MapboxDirections |
build()
Build method
|
String |
getAccessToken() |
String |
getAnnotation()
returns one or a combination of
DirectionsCriteria.ANNOTATION_DISTANCE ,
DirectionsCriteria.ANNOTATION_DURATION , or DirectionsCriteria.ANNOTATION_SPEED . |
String |
getBearings() |
String |
getCoordinates()
The coordinates parameter denotes between which points routing happens.
|
String |
getGeometries() |
String |
getLanguage() |
String |
getOverview() |
String |
getProfile()
The current profile set for usage with the Directions API.
|
String |
getRadiuses()
Radiuses indicate how far from a coordinate a routeable way is searched.
|
String |
getUser() |
Boolean |
isAlternatives() |
Boolean |
isContinueStraight()
Determine whether the route's been set to continue straight or not.
|
Boolean |
isSteps() |
T |
setAccessToken(String accessToken)
Required to call when building
MapboxDirections.Builder . |
T |
setAlternatives(Boolean alternatives)
Optionally, call if you'd like to receive alternative routes besides just one.
|
T |
setAnnotation(String... annotation)
Whether or not to return additional metadata along the route.
|
T |
setBaseUrl(String baseUrl)
Optionally change the APIs base URL to something other then the default Mapbox one.
|
T |
setBearings(double[]... bearings)
Optionally, Use to filter the road segment the waypoint will be placed on by direction and dictates the angle of
approach.
|
T |
setClientAppName(String appName)
Base package name or other simple string identifier
|
T |
setContinueStraight(Boolean continueStraight)
Toggle whether you want the route to always continue straight toward the next destination
or allow for backtracking.
|
T |
setCoordinates(List<com.mapbox.services.commons.models.Position> coordinates)
Set the list of coordinates for the directions service.
|
T |
setDestination(com.mapbox.services.commons.models.Position destination)
Appends the specified destination to the end of the coordinates list.
|
T |
setGeometry(String geometries)
The SDK currently only supports
Polyline geometry (not GeoJSON) to simplify the response. |
T |
setLanguage(String language)
Optionally set the language of returned turn-by-turn text instructions.
|
T |
setOrigin(com.mapbox.services.commons.models.Position origin)
Inserts the specified position at the beginning of the coordinates list.
|
T |
setOverview(String overview)
Optionally, set whether you want the route geometry to be full, simplified, etc.
|
T |
setProfile(String profile) |
T |
setRadiuses(double[] radiuses)
Optionally, set the maximum distance in meters that each coordinate is allowed to move when snapped to a nearby
road segment.
|
T |
setRoundaboutExits(Boolean roundaboutExits)
Optionally, set this to true if you want to enable instructions while exiting roundabouts
and rotaries.
|
T |
setSteps(Boolean steps)
Optionally, call if you'd like to include step information within route.
|
T |
setUser(String user) |
getBaseUrl, getClientAppName, validateAccessToken
public T setGeometry(String geometries)
Polyline
geometry (not GeoJSON) to simplify the response. You do have
the option on whether the precision is 5 or 6 using either DirectionsCriteria.GEOMETRY_POLYLINE
or
DirectionsCriteria.GEOMETRY_POLYLINE6
.geometries
- A String
constant which equals either "polyline"
or "polyline6"
.public T setProfile(String profile)
profile
- Profile stringpublic T setCoordinates(List<com.mapbox.services.commons.models.Position> coordinates)
coordinates
- List of Position
giving origin and destination(s) coordinates.public T setOrigin(com.mapbox.services.commons.models.Position origin)
origin
- Position
of route origin.public T setDestination(com.mapbox.services.commons.models.Position destination)
destination
- Position
of route destination.public T setAccessToken(String accessToken)
MapboxDirections.Builder
.setAccessToken
in class MapboxBuilder
accessToken
- Mapbox access token, You must have a Mapbox account inorder to use
this library.public T setAlternatives(Boolean alternatives)
alternatives
- true if you'd like alternative routes, else false.public T setOverview(String overview)
overview
- String defining type of overview you'd like the API to give. Use one of
the constants.public T setBearings(double[]... bearings)
setRadiuses(double[])
parameter. The parameter takes two values per waypoint:
the first is an angle clockwise from true north between 0 and 360. The second is the range of degrees the angle
can deviate by. We recommend a value of 45 degrees or 90 degrees for the range, as bearing measurements tend to
be inaccurate. This is useful for making sure we reroute vehicles on new routes that continue traveling in their
current direction. A request that does this would provide bearing and radius values for the first waypoint and
leave the remaining values empty. If provided, the list of bearings must be the same length as the list of
waypoints, but you can skip a coordinate and show its position by passing in a double array with no values
included like so: new double[] {}
.bearings
- a double array with two values indicating the angle and the other value indicating the deviating
range.public T setRadiuses(double[] radiuses)
Double.POSITIVE_INFINITY
. If no routable road
is found within the radius, a NoSegment
error is returned.radiuses
- double array containing the radiuses defined in unit meters.public T setSteps(Boolean steps)
steps
- true if you'd like step information.public T setContinueStraight(Boolean continueStraight)
continueStraight
- boolean true if you want to always continue straight, else false.public T setAnnotation(String... annotation)
DirectionsCriteria.ANNOTATION_DISTANCE
, DirectionsCriteria.ANNOTATION_DURATION
,
DirectionsCriteria.ANNOTATION_DURATION
and DirectionsCriteria.ANNOTATION_CONGESTION
. Several
annotation can be used by separating them with ,
.annotation
- String referencing one of the annotation direction criteria's.public T setLanguage(String language)
en
for English.language
- The locale in which results should be returned.public T setRoundaboutExits(Boolean roundaboutExits)
roundaboutExits
- true if exit on a roundabout is allowed.public String getUser()
public String getProfile()
public String getCoordinates()
{longitude},{latitude};{longitude},{latitude}[;{longitude},{latitude} ...]
- Each coordinate is a pair of a longitude double and latitude double, which are separated by a ,
- Coordinates are separated by a ; from each other
- A query must have at least 2 coordinates and at most 25 coordinates (at most 3 when the profile is
DirectionsCriteria.PROFILE_DRIVING_TRAFFIC
)
public String getAccessToken()
getAccessToken
in class MapboxBuilder
public Boolean isAlternatives()
setAlternatives(Boolean)
to true.public String getGeometries()
DirectionsCriteria.GEOMETRY_GEOJSON
,
DirectionsCriteria.GEOMETRY_POLYLINE
,
or DirectionsCriteria.GEOMETRY_POLYLINE6
public String getOverview()
public String getBearings()
public String getRadiuses()
?radiuses={radius};{radius}}[;{radius} ...].
If no routeble way can be found within the serach radius, a NoRoute error will be returned.
- Radiuses are separated by a ,
- Each radius must be of a value float >= 0
in meters or unlimited (default)
- There must be as many radiuses as there are coordinates
- It is possible to not specify radiuses via ;;, which result in the same behaviour as setting unlimited
public Boolean isSteps()
setSteps(Boolean)
.public Boolean isContinueStraight()
public String getAnnotation()
DirectionsCriteria.ANNOTATION_DISTANCE
,
DirectionsCriteria.ANNOTATION_DURATION
, or DirectionsCriteria.ANNOTATION_SPEED
.public String getLanguage()
public T setClientAppName(String appName)
setClientAppName
in class MapboxBuilder
appName
- base package name or other simple string identifierpublic T setBaseUrl(String baseUrl)
setBaseUrl
in class MapboxBuilder
baseUrl
- base url used as end pointpublic Boolean allowsRoundaboutExits()
setRoundaboutExits(Boolean)
.public MapboxDirections build() throws ServicesException
build
in class MapboxBuilder
ServicesException
- Generic Exception for all things directions.© 2015–2016 Mapbox. All rights reserved.