function getCoffeeLatLon(inpLat, inpLon){
var searchURL = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=coffee&key=AIzaSyCKY43b8fpjLUuagtq1ZdSc477QwFuprew&location=15.7228486,-90.2348";
var firstLat;
var firstLon;
var firstName;
var fullJSON= $.getJSON("https://maps.googleapis.com/maps/api/place/textsearch/json?query=coffee&key=AIzaSyCKY43b8fpjLUuagtq1ZdSc477QwFuprew&location=15.7228486,-90.2348", function(data){
firstLat = data.results[0].geometry.location.lat;
firstLon = data.results[0].geometry.location.lng;
firstName = data.results[0].name;
console.log("checking");
});
var coffeeLatLonName = [firstLat, firstLon, firstName];
return coffeeLatLonName;
}
Oben ist mein Codebeispiel. Während ich online auf die Google Maps-API-URL zugreifen und die vollständigen JSON-Ergebnisse anzeigen kann, wird bei Verwendung in meinem Code die Funktion "Erfolg" meines $ .getJSON-Aufrufs nicht ausgeführt. Ich kann auch die Ergebnisse der URL speichern und diese Datei ohne Problem verwenden.TextSearch gibt die Ausgabe nicht zurück (aber die URL ist gültig)
Warum kann ich die URL nicht direkt in meinem Code verwenden?
Danke.
ich uns helfen kann, bitte vollständige Code senden – KingRider