Module: Gistance::Client::DistanceMatrix

Included in:
Gistance::Client
Defined in:
lib/gistance/client/distance_matrix.rb

Overview

Methods for the Distance Matrix API

Instance Method Summary collapse

Instance Method Details

#distance_matrix(options = {}) ⇒ Hashie::Mash

Calculate distances for a matrix of origins and destinations.

Examples:

Gistance.distance_matrix(
  origins: ["48.92088132,2.210950607"],
  destinations: ["48.922024,2.206292"]
)

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :origins (Hash)

    an array of origins

  • :destinations (Hash)

    an array of destination

Returns:

  • (Hashie::Mash)

    the distance between origins and destinations

See Also:



18
19
20
21
22
23
# File 'lib/gistance/client/distance_matrix.rb', line 18

def distance_matrix(options={})
  options[:origins] = format_locations_array(options[:origins])
  options[:destinations] = format_locations_array(options[:destinations])

  delete_status_from_response(get(options))
end