測試百度地圖輸入GPS經緯度顯示位置API

1.個人GPS獲取的經緯度作度分秒轉換後爲

34.636055,112.40832html

2.百度API介紹

GPS的座標是WGS84,因此測試APIpython

http://api.map.baidu.com/geocoder?location=34.636055,112.40832&coord_type=wgs84&output=html&src=waaax|GPSTest

能夠用瀏覽器打開或者作app訪問web

3.用python測試api

效果

測試代碼

# -*- coding: utf-8 -*-

"""
Module implementing BaiduMap.
"""

from PyQt4.QtCore import pyqtSignature
from PyQt4.QtGui import QDialog

from Ui_main_ui import Ui_Dialog

#添加
from PyQt4 import QtCore, QtGui
import sys

# 設備ID
LAT = '34.636055'
# 數據流名稱
LON = '112.40832'

class BaiduMap(QDialog, Ui_Dialog):
    """
    Class documentation goes here.
    """
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent widget
        @type QWidget
        """
        QDialog.__init__(self, parent)
        self.setupUi(self)

        address = "http://api.map.baidu.com/geocoder?location=%s,%s&coord_type=wgs84&output=html&src=yourCompanyName|yourAppName"%(LAT,LON)

        url = QtCore.QUrl(address)
        self.webView.load(url)


if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    mycalc = BaiduMap()
    mycalc.show()
    sys.exit(app.exec_())
相關文章
相關標籤/搜索