Just installed phonegap 2.3 and tried to open a maps link that i’ve created. This was working perfectly fine until the update.
I have tweaked the URL scheme to suit the ones in here and i have also tried feeding it a normal url, no matter what i do, i cannot seem to get it to load a link outside the app, whether it be a browser window or the native maps app..
Code:
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;
},
Does anyone have a workaround?
PS, the os detection works and is ugly.. but it works 🙂
Ok, so after much searching and false leads i have found that the URL’s are handled differently in this version of Cordova/Phonegap.
So i found the delegate:
— edit this delegate method is in CDVViewController.m as part of the Cordova project
And added an if-case. The check basically says “is the URL (https or http) and is the URL for (maps.google.com/maps or maps.apple.com – for ios 5 and 6 respectively)
This fixed the issue for maps, there may be some other URL based application references that this doesn’t solve.