gpt4 book ai didi

javascript - 地理编码服务与 gMap 搜索之间的差异结果

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:34:45 32 4
gpt4 key购买 nike

我想获取此地址的经纬度:Boulevard de la Marne Zone industrielle, COULOMMIERS, 77120, France

我将 api 添加到我的页面:

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true"></script>

当我使用 gmaps 时,结果很好,但是当我想通过 API 检索它时:

 geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': myAdress, 'region': 'FR'}, function (results, status) {...});

它执行以下请求:

https://maps.googleapis.com/maps/api/js/GeocodeService.Search?4sBoulevard%20de%20la%20Marne%20%20Zone%20industrielle%20%20COULOMMIERS%2077120%20&7sUS&9sfr-FR&callback=_xdc_._lsoj9s&token=53058

结果在巴马科附近...

如果我使用视口(viewport)边界,它会执行以下请求:

https://maps.googleapis.com/maps/api/js/GeocodeService.Search?4sBoulevard%20de%20la%20Marne%20%20Zone%20industrielle%20%20COULOMMIERS%2077120%20&6m6&1m2&1d40.513799&2d-5.844727000000034&2m2&1d51.727028&2d10.854491999999936&7sUS&9sfr-FR&callback=_xdc_._c84svr&token=29019

更好(在法国)但不是那样

查询在网站 google map 上运行良好: https://maps.google.fr/maps?q=Boulevard+de+la+Marne++Zone+industrielle,++COULOMMIERS,+77120&hl=fr&ll=48.487486,3.922119&spn=1.541855,4.22699&sll=50.485474,25.620117&sspn=23.748757,67.631836&hq=Boulevard+de+la+Marne++Zone+industrielle,++COULOMMIERS,+77120&radius=15000&t=m&z=9

似乎获得它的唯一方法是执行以下请求: http://maps.googleapis.com/maps/api/geocode/json?address=Boulevard%20de%20la%20Marne%20Zone%20industrielle,%20COULOMMIERS,%2077120&components=country:FR&sensor=false

我不明白为什么当我使用视口(viewport)而不是国家时结果不同(两个结果都在视口(viewport)的边界内)

最佳答案

Boulevard de la Marne Zone industrielle, COULOMMIERS, 77120, France 不是地址,而是“地点”。

地理编码器从该输入中找到 Via De La Marne 的位置:

http://www.geocodezip.com/v3_example_geo2.asp?addr1=Boulevard de la Marne Zone industrielle, COULOMMIERS, 77120, France&geocode=1

Found 1 results for Boulevard de la Marne Zone industrielle, COULOMMIERS, 77120, France
[ 0 ]: Av De La Marne, Bamako, Mali (12.6417952, -7.988396299999977)

Places API 的第一个结果看起来更正确:

http://www.geocodezip.com/v3_example_geo2.asp?addr1=Boulevard de la Marne Zone industrielle, COULOMMIERS, 77120, France&place=1

Found 20 results for Boulevard de la Marne Zone industrielle, COULOMMIERS, 77120, France
[ 0 ]: Zone Industrielle, Boulevard de la Marne, Coulommiers, France (48.804329, 3.0923729999999523)
[ 1 ]: Boulevard de la Marne, Coulommiers, France (48.803048, 3.092110000000048)
[ 2 ]: 21 Boulevard de la Marne, Coulommiers, France (48.806634, 3.0937430000000177)
...

关于javascript - 地理编码服务与 gMap 搜索之间的差异结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16192571/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com