对乌克兰邮政编码进行地理编码的最有效和准确的方法是什么?使用内置的地理编码对象会导致大量模糊的结果(许多邮政编码只返回一般区域)。
我可以通过JavaScript插入免费的乌克兰邮政编码地理编码服务吗?
答案 0 :(得分:2)
如果我理解您的问题是正确的,您只需设置componentRestrictions
即可。可能看起来像这样:
doGeocode: function (address, postal_code, callback) {
console.log("TEST: " + address.toString());
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
'address': address,
'componentRestrictions': {
'postalCode': postal_code,
'country': 'de' //change this to the Code of Ukraine
}
}, function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
console.log(results);
callback(results);
} else {
//Error handling
alert('Geocode was not successful for the following reason: ' + status);
}
});
注意:当然,您必须在此处设置乌克兰的国家/地区代码。而且,因为你没有提到你有哪些地址或者lat / lng的信息,我只是给你一个地址的例子。