Ответ 1
Вы можете использовать API Google GeoCode для запроса широты и долготы для почтового индекса и оттуда.
URL-адрес запроса API будет выглядеть так, если вы хотите сделать это напрямую или через какой-либо другой носитель
http://maps.googleapis.com/maps/api/geocode/json?address=50323&sensor=false
Где 50323 - ваш почтовый индекс.
Или вы можете использовать API-интерфейс google Javascript для выполнения всего этого через jQuery.
var geocoder; //To use later
var map; //Your map
function initialize() {
geocoder = new google.maps.Geocoder();
//Default setup
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
//Call this wherever needed to actually handle the display
function codeAddress(zipCode) {
geocoder.geocode( { 'address': zipCode}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
//Got result, center the map and put it out there
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}