我正在通过Phonegap与谷歌地图集成的项目。
当数据连接不存在时,在浏览器中获取错误页面,如“网页不可用”,如下所示。
有人能帮帮我吗?
答案 0 :(得分:0)
请尝试检查连接,如果其数据已连接,则可以进行地图呼叫。您也无法在离线时提出任何跨域请求
样品
function checkConnection() {
var networkState = navigator.connection.type;
var states = {};
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.CELL] = 'Cell generic connection';
states[Connection.NONE] = 'No network connection';
alert('Connection type: ' + states[networkState]);
}
checkConnection();
请参阅phonegap文档更多选项 http://docs.phonegap.com/en/3.1.0/cordova_connection_connection.md.html#Connection