我想得到这个地址的经纬度: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
结果在巴马科附近......
如果我使用视口边界,它会执行以下请求:
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
它更好(它在法国),但事实并非如此
似乎获得它的唯一方法是执行以下请求: http://maps.googleapis.com/maps/api/geocode/json?address=Boulevard%20de%20la%20Marne%20Zone%20industrielle, %20COULOMMIERS ,%2077120&components=国家:FR&sensor=false
我不明白为什么当我使用视口而不是国家时结果不同(这两个结果都在视口的范围内)