ExMaps v1.1.0-rc.1 ExMaps View Source

Public ExMaps application interface.

Link to this section Summary

Types

Required Distance Calculations API request parameters

Required Distance Matrix API request parameters

Shared APIs request optional parameters. Detailed description can be found below: https://developers.google.com/maps/documentation/directions/intro

General params

Functions

Returns calculated directions between provided locations. It checkes wether the directions with same set of options were alread calculated and set in cache, if not, it calls Google API, fetches the result, saves it in cache and returns it

Returns travel distance and time for a matrix of origins and destinations. It checkes wether the matrix with same set of options was alread requested and set in cache, if not, it calls Google API, fetches the result, saves it in cache and returns it

Link to this section Types

Link to this type alternatives() View Source
alternatives() :: boolean()
Link to this type arrival_time() View Source
arrival_time() :: integer()
Link to this type avoid_value() View Source
avoid_value() :: :tolls | :highways | :ferries | :indoor
Link to this type coordinates() View Source
coordinates() :: [%{origin: waypoint(), destination: waypoint()}]

Required Distance Calculations API request parameters.

  • origin — It can be passed in three different forms, as the address string, latitude/longitude tuple or map containing PlaceID.
  • destination — It can be passed in three different forms, as the address string, latitude/longitude tuple or map containing PlaceID.
Link to this type departure_time() View Source
departure_time() :: integer()
Link to this type destinations() View Source
destinations() :: String.t() | {float(), float()} | %{place_id: String.t()}
Link to this type language() View Source
language() :: String.t()
Link to this type matrix_coordinates() View Source
matrix_coordinates() :: [%{origins: [waypoint()], destinations: [waypoint()]}]

Required Distance Matrix API request parameters.

  • origin — It can be passed in three different forms, as the address string, latitude/longitude tuple or map containing PlaceID.
  • destination — It can be passed in three different forms, as the address string, latitude/longitude tuple or map containing PlaceID.
Link to this type mode() View Source
mode() :: :driving | :walking | :bicycling | :transit

Shared APIs request optional parameters. Detailed description can be found below: https://developers.google.com/maps/documentation/directions/intro

  • mode - Specifies the mode of transport to use when calculating directions. Defaults to driving.
  • waypoints - A list of waypoints.
  • alternatives - If set to true, API may provide more than one route alternative.
  • avoid - List of specific routes to avoid.
  • language - Directions may be provided in specified language (but not all JSON / XML answer fields)
  • units - If not present, unit system of the origin’s country or region will be returned.
  • region - Biasing on a specific region.
  • arrival_time - Desired arrival time in seconds since midnight, January 1, 1970 UTC.
  • departure_time - Desired departure time in seconds since midnight, January 1, 1970 UTC.
  • traffic_model - It may only be specified for driving directions where the request includes a departure_time.
  • transit_mode - It may only be specified for transit directions.
  • transit_routing_preference - It may bias the options returned.
Link to this type options() View Source
options() :: [{:option, term()}]
Link to this type origins() View Source
origins() :: String.t() | {float(), float()} | %{place_id: String.t()}
Link to this type output_format() View Source
output_format() :: :json | :xml

General params.

Format of the output of Google Maps API call. Please note that json is recommended by Google docs.

Link to this type protocol() View Source
protocol() :: :https | :http
Link to this type traffic_model() View Source
traffic_model() :: :best_guess | :pessimistic | :optimistic
Link to this type transit_mode() View Source
transit_mode() :: :bus | :subway | :train | :tram | :rail
Link to this type transit_routing_preference() View Source
transit_routing_preference() :: :less_walking | :fewer_transfers
Link to this type units() View Source
units() :: :metric | :imperial
Link to this type waypoint() View Source
waypoint() :: String.t() | {float(), float()} | %{place_id: String.t()}
Link to this type waypoints() View Source
waypoints() :: :waypoints

Link to this section Functions

Link to this function get_directions(coordinates, options \\ []) View Source
get_directions(coordinates(), options()) :: [map()]

Returns calculated directions between provided locations. It checkes wether the directions with same set of options were alread calculated and set in cache, if not, it calls Google API, fetches the result, saves it in cache and returns it.

Examples

iex> ExMaps.get_directions([%{origin: "Warsaw", destination: "Amsterdam"}], units: :metric)
[%{"geocoded_waypoints" => ... }]
Link to this function get_distance_matrix(matrix_coordinates, options \\ []) View Source
get_distance_matrix(matrix_coordinates(), options()) :: [map()]

Returns travel distance and time for a matrix of origins and destinations. It checkes wether the matrix with same set of options was alread requested and set in cache, if not, it calls Google API, fetches the result, saves it in cache and returns it.

Examples

iex> ExMaps.get_distance_matrix([%{origins: ["Warsaw", "Kraków"], destinations: ["Amsterdam", "Utrecht"]}], language: "pl")
[%{"destination_addresses" => ...}]