刚刚安装了 phonegap 2.3 并尝试打开我创建的地图链接。在更新之前,这一切都很好。
我已经调整了 URL 方案以适合这里的方案,并且我还尝试为它提供一个正常的 url,无论我做什么,我似乎都无法让它加载应用程序外部的链接,无论是浏览器窗口还是本机地图应用程序..
代码:
openDeviceMapsApplication: function(address, lat, lon) {
var query = '?';
address = address + ", Australia";
address = encodeURI(address);
if (address[0] !== '.') {
query += 'q=' + address + '&';
} else {
query += 'q=' + lat + ',' + lon + '&';
}
query += 'z=15';
var url = 'http://maps.google.com/maps';
var osVersion = "not detected";
console.log("detect");
if(/OS [2-4](_\d)(_\d)? like Mac OS X/i.test(navigator.userAgent)) { //is it ios 2-4?
url = 'http://maps.google.com/maps'; osVersion = "ios 2-4";
console.log("ios2-4");
} else if(/CPU like Mac OS X/i.test(navigator.userAgent)) { // ios 1?!?!
url = 'http://maps.google.com/maps'; osVersion = "ios 1";
console.log("ios4");
} else if(/OS [5](_\d)(_\d)? like Mac OS X/i.test(navigator.userAgent)) { //ios 5?
url = 'http://maps.google.com/maps'; osVersion = "ios 5";
console.log("ios5");
} else{//ios 6 or greater
url = 'http://maps.apple.com/'; osVersion = "ios 6 or greater";
console.log("ios6");
}
url += query;
console.log(url);
window.location.href = url;
return;
},
有人有解决方法吗?
PS,操作系统检测有效且丑陋..但有效:)