Map Path Planning geopath. py
#-*-Coding: UTF-8-*-import androidimport urllibimport urllib2import jsonimport sysprint sys. getdefaultencoding () reload (sys) sys. setdefaultencoding ('utf-8') droid = android. android () city = droid. dialogGetInput (u "geocode", u "Enter start:", u 'guangzhou '). resultcity = urllib2.quote (city) print u 'start point:', cityurl = u 'HTTP: // maps.google.com/maps/api/geocode/json? Address = % s & sensor = true & language = zh-CN 'handler = urllib2.urlopen (url % city) js = json. load (handler) handler. close () address = js ['results'] [0] ['address _ components'] for ad in address: print ad ['long _ name'] location = js ['results'] [0] ['ry ry'] ['location'] startLat = location ['lat'] startLng = location ['lng '] print jscity = droid. dialogGetInput (u "geocode", u "Please input end:", u 'zhuhai '). resultcity = urllib2.quot E (city) print u 'destination: ', cityurl = u'http: // maps.google.com/maps/api/geocode/json? Address = % s & sensor = true & language = zh-CN 'handler = urllib2.urlopen (url % city) js = json. load (handler) handler. close () address = js ['results'] [0] ['address _ components'] for ad in address: print ad ['long _ name'] location = js ['results'] [0] ['ry ry'] ['location'] endLat = location ['lat'] endLng = location ['lng '] print js # Path Planning: url = 'HTTP: // maps.google.com/maps? F = d & saddr = % s % 20% s & daddr = % s % 20% s & hl = zh '% (startLat, startLng, endLat, endLng) print urldroid. startActivity ('android. intent. action. view', url)
Tested on android 4.1 pad.
Reference http://blog.csdn.net/xyz_lmn/article/details/5968056