AppleMapsServer (apple_maps_server v0.2.0)

Copy Markdown View Source

Elixir client for the Apple Maps Server API.

The public surface is intentionally small:

AppleMapsServer.search("coffee")
AppleMapsServer.search_autocomplete("cof")
AppleMapsServer.geocode("1 Infinite Loop, Cupertino, CA")
AppleMapsServer.reverse_geocode(%{latitude: 37.3318, longitude: -122.0312})
AppleMapsServer.token()

Configuration

config :apple_maps_server,
  maps_id: System.get_env("APPLE_MAPS_ID"),
  team_id: System.get_env("APPLE_TEAM_ID"),
  key_id: System.get_env("APPLE_MAPS_KEY_ID"),
  private_key: System.get_env("APPLE_MAPS_PRIVATE_KEY"),
  base_url: "https://maps-api.apple.com",
  token_ttl_seconds: 300

Every function also accepts per-call opts that override the application config.

Summary

Functions

Directions from an origin to a destination. Origin/destination may be a free-text address or a "lat,lon" string.

ETAs from an origin to up to ten destinations. destinations accepts either a "lat,lon|lat,lon" string or a list of such coordinate strings — the list form is joined with the | delimiter Apple expects.

Forward-geocode a free-text address.

Reverse-geocode a coordinate pair.

Search for places matching a free-text query. See Apple docs for full parameter list.

Return autocomplete suggestions for a partial query.

Return a cached-per-call Apple Maps access token (after the JWT → token exchange).

Types

opts()

@type opts() :: keyword()

response()

@type response() :: {:ok, map()} | {:error, term()}

Functions

directions(origin, destination, opts \\ [])

@spec directions(String.t(), String.t(), opts()) :: response()

Directions from an origin to a destination. Origin/destination may be a free-text address or a "lat,lon" string.

etas(origin, destinations, opts \\ [])

@spec etas(String.t(), String.t() | [String.t()], opts()) :: response()

ETAs from an origin to up to ten destinations. destinations accepts either a "lat,lon|lat,lon" string or a list of such coordinate strings — the list form is joined with the | delimiter Apple expects.

geocode(address, opts \\ [])

@spec geocode(String.t(), opts()) :: response()

Forward-geocode a free-text address.

reverse_geocode(map, opts \\ [])

@spec reverse_geocode(%{latitude: number(), longitude: number()}, opts()) ::
  response()

Reverse-geocode a coordinate pair.

search(query, opts \\ [])

@spec search(String.t(), opts()) :: response()

Search for places matching a free-text query. See Apple docs for full parameter list.

search_autocomplete(query, opts \\ [])

@spec search_autocomplete(String.t(), opts()) :: response()

Return autocomplete suggestions for a partial query.

token(opts \\ [])

@spec token(opts()) :: {:ok, String.t()} | {:error, term()}

Return a cached-per-call Apple Maps access token (after the JWT → token exchange).