Python for android: Map Path Planning

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.