Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class PhotonPlacesProvider
- Object
- PhotonPlacesProvider
ImplementsPlacesProvider
Place search over Photon, the OpenStreetMap search-as-you-type service.
It needs no key. The public server at photon.komoot.io is for light
use; point setBaseUrl at your own instance for production traffic.
Photon returns coordinates with each suggestion, so getDetails answers
from the last results and makes no request.
Constructors
public PhotonPlacesProvider() |
Methods
Inherited methods
Constructor details
PhotonPlacesProvider
public PhotonPlacesProvider()Method details
setBaseUrl
public void setBaseUrl(String baseUrl)Sets the server,
https://photon.komoot.io by default.Parameters
baseUrlString- the server URL
setLimit
public void setLimit(int limit)Sets the number of suggestions, 6 by default.
Parameters
limitint- the count
setTransport
public void setTransport(CloudHttpTransport transport)Replaces the HTTP transport, for tests or a custom stack.
Parameters
transportCloudHttpTransport- the transport
autocomplete
public AsyncResource<List<PlacePrediction>> autocomplete(String input, String sessionToken, LatLng bias)Suggests places for partial input.
Parameters
inputString- what the user typed
sessionTokenString- groups the requests of one search for billing; may be ignored
biasLatLng- prefers results near this point, may be null
Returns
the suggestions
getDetails
public AsyncResource<PlaceDetails> getDetails(String placeId, String sessionToken)Resolves a suggestion. This ends the session the token names.
Parameters
placeIdString- the ID of a prediction
sessionTokenString- the token used for the autocomplete requests
Returns
the details
parseFeatures
public static List<PlaceDetails> parseFeatures(Map<String, Object> json)Reads the features of a Photon GeoJSON response.
Parameters
jsonMap<String, Object>- the parsed response
Returns
one entry per feature with a point geometry