我有格式的街道地址
1 Rue du Four, 60200 COMPIEGNE, France
2 Rue de Lancry, 60200 COMPIEGNE, France
地址列表最多可达10万。十万。
目前我正在使用谷歌gecode,但它有一些限制,比如每天2500。我一直犯这个错误。
google.maps.GeocodeStatus.OVER_QUERY_LIMIT
然后我设法用一个像下面那样的超时来完成
函数代码地址(标记地址){
var address = markersAddress.address;
var name = markersAddress.name;
var info = markersAddress.info;
geocoder.geocode({'address': address}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latLng = results[0].geometry.location;
} else {
if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
setTimeout(function() { codeAddress(markersAddress); }, (timeout * 3));
} else {
console.log('Geocode was not successful for the following reason: ' + status);
}
}
});
然而,当有100000条记录时,这种方法会导致浏览器速度缓慢。那么,有没有更好的方法可以使用api获取地理编码呢?
离线地理编码地址并"缓存"结果(符合服务条款的时间少于30天),使用坐标显示标记。
更多细节:谷歌地图文档中的地理编码策略文章。