Если это поможет ... Вот как вы можете использовать геокодер Google, чтобы получить лат / lng для почтового индекса.Скажем, у вас есть ввод HTML с идентификатором 'location' (используется виджет автозаполнения jqueryui):
// insert a div for autocomplete results
$("#location").after('<div id="location-results"></div>');
$("#location").autocomplete({
appendTo:$("#location-results"),
minLength: 3,
open: acOpen,
select: acSelect,
close: acClose,
source: acSource
});
function acOpen(event, ui){
// no op, but put code here to handle results list open if you need it
}
function acSelect(event, ui){
// fired when user selects a result from the autocomplete list
// assuming you are using the json2.js library for json parsing/decoding
alert(JSON.stringify(ui.item));
// the lat/lng is in ui.item.latLng.lat() and ui.item.latLng.lng()
// ui.item.latLng is of type google.maps.LatLng (see v3 api)
}
function function acClose(event, ui){
// no op, but put code here to handle results list close if you need it
}
function acSource(request, response) {
// implements the autocomplete source for the widget
geocoder.geocode( {'address': request.term }, function(results, status) {
if(undefined!==results){
var postal_code='';
var city = '';
var state = '';
var country = '';
response($.map(results, function(item) {
$.each(item.address_components, function(item_i, item_v){
$.each(item_v.types, function(type_i, type_v){
switch(type_v){
case "locality": case "administrative_area_level_3":
city = item_v.long_name;
break;
case "administrative_area_level_2":
break;
case "street_number":
break;
case "route":
break;
case "administrative_area_level_1":
state = item_v.long_name;
break;
case "country":
country = item_v.long_name;
break;
case "postal_code":
postal_code = item_v.long_name;
break;
}
});
});
// the object that gets returned and is ui.item on select event
return {
label : item.formatted_address,
value : item.formatted_address,
latLng : item.geometry.location,
country : country,
state : state,
city : city,
postal_code : postal_code,
source : "google"
};
}));
}
}
}
}
геокодер Google может геокодировать почтовые индексы, без проблем.