vous pouvez utiliser google's geocoding pour obtenir les coordonnées de vos codes postaux
EDIT: Je ne aime pas vraiment vous changer le sens de la question comme ça, mais ok. S'il vous plaît essayer sth comme ça (ce n'est pas testé):
// Creating an array that will contain the coordinates
// for New York, San Francisco, and Seattle
var places = [];
// Adding a LatLng object for each city
//places.push(new google.maps.LatLng(40.756, -73.986));
//places.push(new google.maps.LatLng(37.775, -122.419));
//places.push(new google.maps.LatLng(47.620, -122.347));
//places.push(new google.maps.LatLng(-22.933, -43.184));
var result;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "http://maps.googleapis.com/maps/api/geocode/json?address=your+code&sensor=false",true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
result = eval('(' + xmlhttp.responseText + ')');
if (result.status == "OK") {
var location = new google.maps.LatLng(result.results[0].geometry.location.lat, result.results[0].geometry.location.lng);
places.push(location);
cela devrait probablement fonctionner, malgré d'éventuelles erreurs mineures.
EDIT2: Je viens maintenant trouvé simpler solution:
// Creating an array that will contain the coordinates
// for New York, San Francisco, and Seattle
var places = [];
// Adding a LatLng object for each city
//places.push(new google.maps.LatLng(40.756, -73.986));
//places.push(new google.maps.LatLng(37.775, -122.419));
//places.push(new google.maps.LatLng(47.620, -122.347));
//places.push(new google.maps.LatLng(-22.933, -43.184));
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': "your+code"}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
//var marker = new google.maps.Marker({
//map: map,
//position: results[0].geometry.location
//});
places.push(results[0].geometry.location);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
Merci, Je ne sais pas où commencer avec elle et encore moins de fusionner avec le code actuel je. – Rob
Regardez le site que j'ai fourni le lien vers et: http://www.w3schools.com/xml/xml_http.asp , il suffit de construire votre demande comme: http://maps.googleapis.com/maps/api/geocode/json? adresse = SW1A + 0AA eval json réponse de google et vous êtes prêt à partir – slawekwin
oups oublié à propos de capteur dans la requête de géocodage: maps.googleapis.com/maps/api/geocode/json?address=SW1A+0AA&sensor = false – slawekwin