Class PhotonPlacesProvider

java.lang.Object
com.codename1.maps.places.PhotonPlacesProvider
All Implemented Interfaces:
PlacesProvider

public class PhotonPlacesProvider extends Object implements PlacesProvider

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.

  • Constructor Details

    • PhotonPlacesProvider

      public PhotonPlacesProvider()
  • Method Details

    • setBaseUrl

      public void setBaseUrl(String baseUrl)

      Sets the server, https://photon.komoot.io by default.

      Parameters
      • baseUrl: the server URL
    • setLimit

      public void setLimit(int limit)

      Sets the number of suggestions, 6 by default.

      Parameters
      • limit: the count
    • setTransport

      public void setTransport(CloudHttpTransport transport)

      Replaces the HTTP transport, for tests or a custom stack.

      Parameters
      • transport: the transport
    • autocomplete

      public AsyncResource<List<PlacePrediction>> autocomplete(String input, String sessionToken, LatLng bias)
      Description copied from interface: PlacesProvider

      Suggests places for partial input.

      Parameters
      • input: what the user typed

      • sessionToken: groups the requests of one search for billing; may be ignored

      • bias: prefers results near this point, may be null

      Returns

      the suggestions

      Specified by:
      autocomplete in interface PlacesProvider
    • getDetails

      public AsyncResource<PlaceDetails> getDetails(String placeId, String sessionToken)
      Description copied from interface: PlacesProvider

      Resolves a suggestion. This ends the session the token names.

      Parameters
      • placeId: the ID of a prediction

      • sessionToken: the token used for the autocomplete requests

      Returns

      the details

      Specified by:
      getDetails in interface PlacesProvider
    • parseFeatures

      public static List<PlaceDetails> parseFeatures(Map<String,Object> json)

      Reads the features of a Photon GeoJSON response.

      Parameters
      • json: the parsed response
      Returns

      one entry per feature with a point geometry