from urllib2 import urlopen
import simplejson
g_api = 'http://maps.googleapis.com/maps/api/directions/json'
url = '%s?origin=%s&destination=%s&sensor=false&mode=driving' % (g_api, origin, destination)
request = urlopen(url)
results = simplejson.load(request)
meter_distance = 0
seconds_distance = 0
for route in results['routes']:
print route['summary']
for leg in route['legs']:
meter_distance = meter_distance + leg['distance']['value']
seconds_distance = seconds_distance + leg['duration']['value']
Friday, 16 August 2013
Python: fetch google maps directions
Wednesday, 14 August 2013
Javascript get current DateTime in SQL format
function getCurrentDateTime(){
var currentdate = new Date();
//format: "2013-08-02T18:00:00B"
//Iso Zone: B
var datetime = "" + currentdate.getFullYear() + "-" + (currentdate.getMonth() + 1) + "-" + currentdate.getDate() + "T" + currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds() + "B";
return datetime;
}
Subscribe to:
Posts (Atom)