Mushi

Distance between points

Jun 6th, 2017
612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.50 KB | None | 0 0
  1. url1="https://maps.googleapis.com/maps/api/distancematrix/json?origins=+"+current_user.enderecos.collect(&:cep)[0]
  2.           url2="&destinations=+"+loja.cep
  3.           url3="&mode=bicycling&language=pt-BR&key=AIzaSyBRADWHRl0s_0eIXx7YJL9nwDsjaYGF-iU"
  4.           url = url1+url2+url3
  5.           require 'net/http'
  6.           require 'json'
  7.           result = Net::HTTP.get(URI.parse(url))
  8.           json = JSON.parse(result)
  9.           reviews = json['rows']
  10.           reviews[0].to_s.split('=>')[3].split('"')[1]
Advertisement
Add Comment
Please, Sign In to add comment