public abstract static class MapboxGeocoding.Builder
extends java.lang.Object
By default, the geocoding mode is set to mapbox.places. The mode can be changed to mapbox.places-permanent to enable batch and permanent geocoding. For more information about mapbox.places-permanent, contact Mapbox sales.
Note to contributors: All optional booleans in this builder use the object Boolean
rather than the primitive to allow for unset (null) values.
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
abstract MapboxGeocoding.Builder |
accessToken(java.lang.String accessToken)
Required to call when this is being built.
|
abstract MapboxGeocoding.Builder |
autocomplete(java.lang.Boolean autocomplete)
This controls whether autocomplete results are included.
|
abstract MapboxGeocoding.Builder |
baseUrl(java.lang.String baseUrl)
Optionally change the APIs base URL to something other then the default Mapbox one.
|
MapboxGeocoding.Builder |
bbox(com.mapbox.geojson.BoundingBox bbox)
Limit the results to a defined bounding box.
|
MapboxGeocoding.Builder |
bbox(double minX,
double minY,
double maxX,
double maxY)
Limit the results to a defined bounding box.
|
MapboxGeocoding.Builder |
bbox(com.mapbox.geojson.Point southwest,
com.mapbox.geojson.Point northeast)
Limit the results to a defined bounding box.
|
abstract MapboxGeocoding.Builder |
bbox(java.lang.String bbox)
Limit the results to a defined bounding box.
|
MapboxGeocoding |
build()
Build a new
MapboxGeocoding object. |
abstract MapboxGeocoding.Builder |
clientAppName(java.lang.String clientAppName)
Base package name or other simple string identifier.
|
MapboxGeocoding.Builder |
country(java.util.Locale country)
Add a single country locale to restrict the results.
|
MapboxGeocoding.Builder |
country(java.lang.String... country)
Limit results to one or more countries.
|
abstract MapboxGeocoding.Builder |
country(java.lang.String country)
Limit results to one or more countries.
|
abstract MapboxGeocoding.Builder |
fuzzyMatch(java.lang.Boolean fuzzyMatch)
Specify whether the Geocoding API should attempt approximate, as well as exact,
matching when performing searches (true, default), or whether it should opt out
of this behavior and only attempt exact matching (false).
|
MapboxGeocoding.Builder |
geocodingTypes(java.lang.String... geocodingTypes)
This optionally can be set to filter the results returned back after making your forward or
reverse geocoding request.
|
MapboxGeocoding.Builder |
intersectionStreets(java.lang.String streetOneName,
java.lang.String streetTwoName)
Specify the two street names for intersection search.
|
MapboxGeocoding.Builder |
languages(java.util.Locale... languages)
This optionally specifies the desired response language for user queries.
|
abstract MapboxGeocoding.Builder |
languages(java.lang.String languages)
This optionally specifies the desired response language for user queries.
|
MapboxGeocoding.Builder |
limit(int limit)
This optionally specifies the maximum number of results to return.
|
abstract MapboxGeocoding.Builder |
mode(java.lang.String mode)
This sets the kind of geocoding result you desire, either ephemeral geocoding or batch
geocoding.
|
MapboxGeocoding.Builder |
proximity(com.mapbox.geojson.Point proximity)
Bias local results base on a provided
Point . |
MapboxGeocoding.Builder |
query(com.mapbox.geojson.Point point)
Perform a reverse geocode on the provided
Point . |
abstract MapboxGeocoding.Builder |
query(java.lang.String query)
This method can be used for performing a forward geocode on a string representing a address
or POI.
|
abstract MapboxGeocoding.Builder |
reverseMode(java.lang.String reverseMode)
Set the factors that are used to sort nearby results.
|
abstract MapboxGeocoding.Builder |
routing(java.lang.Boolean routing)
Specify whether to request additional metadata about the recommended navigation destination
corresponding to the feature (true) or not (false, default).
|
public MapboxGeocoding.Builder query(@NonNull com.mapbox.geojson.Point point)
Point
. Only one point can be passed in as
the query and isn't guaranteed to return a result. If you
want to do a batch reverse Geocode, you can use the query(String)
method
separating them with a semicolon. For more information about batch geocoding, contact Mapbox sales.point
- a GeoJSON point which matches to coordinate you'd like to reverse geocodepublic abstract MapboxGeocoding.Builder query(@NonNull java.lang.String query)
query
- a String containing the text you'd like to forward geocodepublic abstract MapboxGeocoding.Builder mode(@NonNull java.lang.String mode)
To access batch geocoding, contact Mapbox sales. If you do not have access to batch geocoding, it will return an error code rather than a successful result.
Options avaliable to pass in include, GeocodingCriteria.MODE_PLACES
for a ephemeral
geocoding result (default) or GeocodingCriteria.MODE_PLACES_PERMANENT
for
batch and permanent geocoding.
mode
- mapbox.places or mapbox.places-permanent for batch and permanent geocodingpublic MapboxGeocoding.Builder proximity(@NonNull com.mapbox.geojson.Point proximity)
Point
. This oftentimes increases accuracy in
the returned results.proximity
- a point defining the proximity you'd like to bias the results aroundpublic MapboxGeocoding.Builder geocodingTypes(@NonNull java.lang.String... geocodingTypes)
GeocodingCriteria.GeocodingTypeCriteria
are allowed.
Note that GeocodingCriteria.TYPE_POI_LANDMARK
returns a subset of the results
returned by GeocodingCriteria.TYPE_POI
. More than one type can be specified.
geocodingTypes
- optionally filter the result types by one or more defined types inside
the GeocodingCriteria.GeocodingTypeCriteria
public MapboxGeocoding.Builder country(java.util.Locale country)
country
- limit geocoding results to onepublic MapboxGeocoding.Builder country(java.lang.String... country)
country
- limit geocoding results to onepublic abstract MapboxGeocoding.Builder country(java.lang.String country)
country
- limit geocoding results to onepublic abstract MapboxGeocoding.Builder autocomplete(java.lang.Boolean autocomplete)
washingto
could include washington even
though only the prefix matches. Autocomplete is useful for offering fast, type-ahead results
in user interfaces.
If your queries represent complete addresses or place names, you can disable this behavior and exclude partial matches by setting this to false, the defaults true.
autocomplete
- optionally set whether to allow returned results to attempt prediction of
the full words prior to the user completing the search termspublic MapboxGeocoding.Builder bbox(com.mapbox.geojson.BoundingBox bbox)
MapboxGeocoding.proximity()
, this will strictly
limit results to within the bounding box only. If simple biasing is desired rather than a
strict region, use proximity instead.bbox
- the bounding box as a BoundingBox
public MapboxGeocoding.Builder bbox(com.mapbox.geojson.Point southwest, com.mapbox.geojson.Point northeast)
MapboxGeocoding.proximity()
, this will strictly
limit results to within the bounding box only. If simple biasing is desired rather than a
strict region, use proximity instead.northeast
- the northeast corner of the bounding box as a Point
southwest
- the southwest corner of the bounding box as a Point
public MapboxGeocoding.Builder bbox(double minX, double minY, double maxX, double maxY)
MapboxGeocoding.proximity()
, this will strictly
limit results to within the bounding box only. If simple biasing is desired rather than a
strict region, use proximity instead.minX
- the minX of bounding box when maps facing northminY
- the minY of bounding box when maps facing northmaxX
- the maxX of bounding box when maps facing northmaxY
- the maxY of bounding box when maps facing northpublic abstract MapboxGeocoding.Builder bbox(@NonNull java.lang.String bbox)
MapboxGeocoding.proximity()
, this will strictly
limit results to within the bounding box only. If simple biasing is desired rather than a
strict region, use proximity instead.bbox
- a String defining the bounding box for biasing results ordered in
minX,minY,maxX,maxY
public MapboxGeocoding.Builder limit(int limit)
limit
- the number of returned resultspublic MapboxGeocoding.Builder languages(java.util.Locale... languages)
Any valid IETF language tag can be submitted, and a best effort will be made to return results in the requested language or languages, falling back first to similar and then to common languages in the event that text is not available in the requested language. In the event a fallback language is used, the language field will have a different value than the one requested.
Translation availability varies by language and region, for a full list of supported regions, see the link provided below.
languages
- one or more locale's specifying the language you'd like results to supportpublic abstract MapboxGeocoding.Builder languages(java.lang.String languages)
Any valid IETF language tag can be submitted, and a best effort will be made to return results in the requested language or languages, falling back first to similar and then to common languages in the event that text is not available in the requested language. In the event a fallback language is used, the language field will have a different value than the one requested.
Translation availability varies by language and region, for a full list of supported regions, see the link provided below.
languages
- a String specifying the language or languages you'd like results to supportpublic abstract MapboxGeocoding.Builder reverseMode(@Nullable java.lang.String reverseMode)
GeocodingCriteria.REVERSE_MODE_DISTANCE
for
nearest feature result (default) or GeocodingCriteria.REVERSE_MODE_SCORE
the notability of features within approximately 1 kilometer of the queried point
along with proximity.reverseMode
- limit geocoding results based on the reverseModepublic abstract MapboxGeocoding.Builder fuzzyMatch(java.lang.Boolean fuzzyMatch)
wahsington
, even
though the query was misspelled.fuzzyMatch
- optionally set whether to allow the geocoding API to attempt
exact matching or not.public abstract MapboxGeocoding.Builder routing(java.lang.Boolean routing)
routing
- optionally set whether to request
additional metadata about the recommended navigation destinationpublic abstract MapboxGeocoding.Builder accessToken(@NonNull java.lang.String accessToken)
ServicesException
will be thrown.accessToken
- Mapbox access token, You must have a Mapbox account inorder to use
the Geocoding APIpublic abstract MapboxGeocoding.Builder clientAppName(@NonNull java.lang.String clientAppName)
clientAppName
- base package name or other simple string identifierpublic abstract MapboxGeocoding.Builder baseUrl(@NonNull java.lang.String baseUrl)
baseUrl
- base url used as end pointpublic MapboxGeocoding.Builder intersectionStreets(@NonNull java.lang.String streetOneName, @NonNull java.lang.String streetTwoName)
streetOneName
- First street name of the intersectionstreetTwoName
- Second street name of the intersectionpublic MapboxGeocoding build()
MapboxGeocoding
object.MapboxGeocoding
using the provided values in this builder