0
我正在開發一個簡單的Android應用程序,使用phonegap發送谷歌地圖地理編碼API請求與拉,局域網的位置並返回一個地址。 使用我的桌面時,一切正常! 一旦我使用adobe phonegap雲構建器構建應用程序,它不起作用。此外,我無法調試,因爲應用程序上沒有提供任何內容。它只是顯示一個空值。Phonegap谷歌地圖API查詢不工作
這可能是一個CORS問題? HTTPS?使用移動用戶代理進行谷歌地圖請求的一些問題?我不確定。感謝任何幫助!
這是我的代碼:
function maps_api(latlng){
var divdata = $('div#data');
divdata.text('cleared');
updateStatus('Starting google api: ');
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
updateStatus(this.responseText);
var myArr = JSON.parse(this.responseText);
var divdata = $('div#data');
divdata.text(myArr["results"][0]["formatted_address"]);
}
else
{
updateStatus(this.responseText);
var divdata = $('div#data');
divdata.text(xhttp.statusText);
}
};
xhttp.open("GET", "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + latlng + "&key=myprivatekey", true);
xhttp.send();
}