Ich brauche etwas Hilfe über meine Entwicklung Google Map. In der Tat, wenn ich versuche, eine Adresse zu geocodieren, gibt Google mir alle Informationen ohne Problem.Google Karte Multi Anfrage mit Geocoder
Aber wenn ich versuche, mehrere Adressen zu geocodieren, ist es Ende google antwortet nicht und ich habe keine Antwort.
Mein Code:
$.ajax({
type: "POST",
url: _URL_SITE + "webservices...",
dataType: "xml",
data: parameters,
//contentType: "application/soap+xml; charset=utf-8",
contentType: "text/xml; charset=utf-8",
headers: {
Accept: '*',
SOAPAction: 'http://127.0.0.1/...'
},
success: function (xml) {
var arr = new Array(30000)
var cpt = 1
var address = [];
var address_id = [];
var codepostal = "";
var i = 0;
$(xml).find('Table').each(function() {
codepostal = $(this).find('cp').text();
address[i] = $(this).find('record_id').text() + '|' + codepostal.substring(0,3) + '* ' + $(this).find('commune').text() + '' + '';
i++;
}); // fin de la fonction jquery
traitement(address);
},
error: function() {
alert('error');
}
});
und hier die Funktion, die Google resquest:
function traitement(addresses, callback) {
var coords = [];
var ville = "";
var cp = "";
var lattitude;
var longitude;
for (var i = 0; i < 50; i++) {
currAddress = addresses[i].split("|");
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': currAddress[1] }, function (results, status) {
if (status == 'OK') {
var coords = results[0].geometry.location
lattitude = coords.lat();
longitude = coords.lng();
var latlng = new google.maps.LatLng(lattitude, longitude);
geocoder.geocode({ 'latLng': latlng }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var elt = results[0].address_components;
for (i in elt) {
if (elt[i].types[0] == 'postal_code')
cp = elt[i].short_name;
if (elt[i].types[0] == 'sublocality')
ville = elt[i].short_name;
if (ville == "") {
if (elt[i].types[0] == 'locality')
ville = elt[i].short_name;
}
}
// function which save google's information
Save(currAddress[0], cp, ville, longitude, lattitude)
return;
} else { alert("error lat long"); }
});
} else { alert("error adresse"); }
return;
});
}
Ich habe einige Beiträge über asynchrone Anfrage usw. lesen Aber ich versuche zu verstehen, warum Google gibt mir 0 Antwort, wenn Iteration meiner Schleife „für“ ist über 50 Wiederholungen.
Thans Sie.
Sie überschreiten möglicherweise die Nutzungsbeschränkungen: https://developers.google.com/maps/documentation/javascript/geocoding#UsageLimits – duncan
Mein google Schlüssel ist prenium, also glaube ich nicht, dass dieses Problem hier ist. –