0
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;
}
以上是我的代码示例。尽管我可以在线访问Google Maps API URL并查看完整的JSON结果,但在我的代码中使用它时,它不会运行我的$ .getJSON调用的'sucess'函数。我也可以保存网址的结果并使用该文件而没有问题。TextSearch不返回输出(但URL有效)
为什么我不能直接在我的代码中使用URL?
谢谢。
我可以帮助我们,请发送完整的代码 – KingRider