Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class PhotonPlacesProvider

  1. Object
  2. 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

public void setBaseUrl(String baseUrl)Sets the server, https://photon.komoot.io by default.
public void setLimit(int limit)Sets the number of suggestions, 6 by default.
public void setTransport(CloudHttpTransport transport)Replaces the HTTP transport, for tests or a custom stack.
public AsyncResource<List<PlacePrediction>> autocomplete(String input, String sessionToken, LatLng bias)Suggests places for partial input.
public AsyncResource<PlaceDetails> getDetails(String placeId, String sessionToken)Resolves a suggestion.
public static List<PlaceDetails> parseFeatures(Map<String, Object> json)Reads the features of a Photon GeoJSON response.

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

baseUrl String
the server URL

setLimit

public void setLimit(int limit)
Sets the number of suggestions, 6 by default.

Parameters

limit int
the count

setTransport

public void setTransport(CloudHttpTransport transport)
Replaces the HTTP transport, for tests or a custom stack.

Parameters

transport CloudHttpTransport
the transport

autocomplete

public AsyncResource<List<PlacePrediction>> autocomplete(String input, String sessionToken, LatLng bias)
Suggests places for partial input.

Parameters

input String
what the user typed
sessionToken String
groups the requests of one search for billing; may be ignored
bias LatLng
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

placeId String
the ID of a prediction
sessionToken String
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

json Map<String, Object>
the parsed response

Returns

one entry per feature with a point geometry