我想获取此地址的纬度和经度: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
更好(在法国)但并非如此
该查询在网站谷歌 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/