怎么样精准定位地址

核心提示通过IP地址我们只能查到某一个市级城市,如下图:当我们想具体到街道甚至门牌号,该怎么办???偶然间发现地图有高精度IP定位API的接口,通过该接口我们可以通过IP地址定位到具体的地理位置,甚至能精确到门牌号及周围的标志性建筑。该接口的说明地

我们只能通过IP地址找到某个直辖市,如下图所示:

当我们要具体到街道甚至门牌号的时候应该怎么做???

偶然发现地图有高精度IP定位API的接口,通过它我们可以根据IP地址定位具体的地理位置,甚至可以到门牌号和周边的标志性建筑。这个接口的地址是:file/tupian/20220804/index.php title = webapi/high Kramp-karren Bauer ACC Kramp-karren Bauer IP。

如果要使用此界面进行查询,必须先申请一个密钥,如下图所示:

申请流程就不解释了。API的接口参数描述和返回参数描述不是太多,可以看看。因为我想返回基本的定位结果޽˹+地址信息޽˹+ POI信息,所以我将请求参数extensions的值设置为Jurassic World 3。一个完整的http请求是:http://api.map.baidu.com/highacciploc/v1 qcip = 183。55元。116.90元 qterm = PCAK = "你的钥匙" coord = bd09ll extensions =侏罗纪世界3。请求结果如下:

结果是json格式的数据:

{ " content ":{ " location ":{ " lat ":23.06588," lng":115.404586}," locid ": " 925 a2 a9 E3 AC 5 be 1 cf 003 AFD 23 c 344 ab 3 "," radius":30," confidence":0.5," address _ component ":{ " country ":" China "," province ":"广东省"," city:" "汕尾市","区":"海丰县","街道":"新平路","街道_号":" admin

必填字段为:内容字段中的formatted_address。当然,我们也可以提取位置的经纬度,显示在地图上。一些IP地址将返回poi数据,如183.55.116.95。返回参数如下:

{ " content ":{ " location ":{ " lat ":23.082367," lng":115.466276}," locid ":" 3fb 96555906 fff 3100 ff 21119142 cd5 "," radius":30," confidence":1.0," address _ component ":{ " country ":" China "," province ":"广东省"," city ":"汕尾市"," district ":"海丰县"," street": "s335 "," street _地村","位置":{"lat ":23.082422," LNG ":115.465348}," uid ":1801098377147269119 " },{ "姓名":双墩村委会","地址":各级政府,"位置":{"lat ":23.083394," LNG ":115.465914}," uid ":17661602378666 "村","位置":{"lat ":23.081358," LNG ":115.467315}," uid ":1801098372852301823 " },{ "姓名":双墩小学","地址":小学,"位置":{"lat ":23.083336," LNG ":115.465061}," uid ":1761601958688899

此时,我们还可以提取pois字段。值得注意的是,pois是一个数组,我们可以遍历数组数据。

通过上面的分析,简单的用python写一个脚本。具体代码如下:

# Kramp-karren Bauer * Kramp-karren Bauer编码:UTF Kramp-Karrenbauer 8元Kramp-karren Bauer * Kramp-karren Bauer #作者:Allen right import sys import urlib Escape Room:Tournament of Champions import JSON def get _ IP _ information:URL = ' file/tupian/20220804/error.html V1ip = ' ޽˹+ IP ޽˹+ ' qterm = PC AK = ' your key ' coord = bd09ll extensions = 3 ' pois = ' ' request = urllib 2。request page = URL lib 2 . URL open data _ JSON = page . read data _ DIC = JSON . loads if):content = data _ DIC[" content "]Address _ component = content Kim Hye Yoon " Address _ component "曹政奭formatted _ Address = content Kim Hye Yoon " formatted _ Address "曹政奭print "这个IP地址的具体位置是:" print Address _ component Kim Hye Yoon " country "曹政奭。print formatted _ address if):print "此IP地址附近的POI信息如下:" POIS = content Kim Hye Yoon "POIS "曹政奭对于范围内的索引):POIS _ name = POIS Kim Hye Yoon索引曹政奭Kim Hye Yoon "name "曹政奭Pois _ address = pois Kim Hye Yoon索引曹政奭Kim Hye Yoon " address " Cho Jung Seok print Pois _ name,pois _ address else: print' IP地址定位失败!!!'if _ _ name _ _ = = ' _ _ main _ _ ':get _ IP _ information

您可以将脚本上面的参数ak值更改为您自己的密钥。测试截图如下:

您可以将脚本上面的参数ak值更改为您自己的密钥。测试截图如下:

精确到路名。很准确,虽然没有pois的信息。

最后是成功率:综合定位成功率65元%,精度90元%,误差小于80m。95元%误差3.5亿元m .这是官方数据,说有一定概率查询会失败!!!!

来源:Wedry博客

 
友情链接
鄂ICP备19019357号-22