python 根據位址反求出經緯度

2021-08-29 10:07:45 字數 985 閱讀 2783

方法一:

import requst

import json

def getlnglat(address):

ak = 'f30c9d52b003c2b3ac089e2672e18baf'

url=""%(ak,address)data=requests.get(url)

contest=data.json()

print(str(contest))

contest=contest['geocodes'][0]['location']

tt = contest.split(',')

return tt[0],tt[1],address[-1]

注意:上面這個方法有個確點,訪問次數過多會被限制訪問,那搞個毛線,來看方法二

方法二:

首先登陸該**:

申請乙個可以使用的ak

import json

from urllib.request

import urlopen, quote

import requests

defgetlnglat

(address):

url = ''

output = 'json'

ak = '申請好的金鑰'

# 瀏覽器端金鑰

uri = url + '?' + 'address=' + address + '&output=' + output + '&ak=' + ak

req = urlopen(uri)

res = req.read().decode()

temp = json.loads(res)

lat = temp['result']['location']['lat']

lng = temp['result']['location']['lng']

return lat, lng

特別鳴謝:

根據經緯度反位址解析

一.首先引入所申請的ak金鑰 二.簡單樣式處理一下 body,html l map r result 三.html 布局 下面的 是用來顯示地圖的 四.js 如下 var map new bmap.map l map map.centerandzoom new bmap.point 116.3287...

Python根據地名獲取經緯度

以下是通過訪問高德地圖介面獲取指定地名的經緯度資訊 import requests import re import json 獲取位址座標 def get get location m name url children key 8325164e247e15eea68b59e89200988b p...

如何用php根據位址獲取經緯度

這裡用的是地圖的介面,你需要先申請的服務秘鑰 ak 地圖有這樣乙個介面 地理編碼 1.php 根據位址獲取經緯度 地圖 public function queryaddress 2.列印出來的效果 array status 0 result array location array 程式設計客棧16...