Class: HkGeo::RouteFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/hk_geo/route_finder.rb

Class Method Summary collapse

Class Method Details

.route(from, to) ⇒ Object



7
8
9
10
11
12
# File 'lib/hk_geo/route_finder.rb', line 7

def self.route(from, to)
  response = RestClient.get("http://maps.googleapis.com/maps/api/directions/json?origin=#{from}&destination=#{to}&sensor=false")
  routes = JSON(response.to_str)
  overview_polyline = routes["routes"].first["overview_polyline"]
  GoogleMapsPolyline.decode_polyline(overview_polyline["points"], overview_polyline["levels"])
end