[TIMOB-5503] MobileWeb: Error occurs when using getCurrentPosition method of Ti.Geolocation module in iPhone
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-06-08T01:45:40.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Backlog |
Components | MobileWeb |
Labels | n/a |
Reporter | Misha Vasko |
Assignee | Maxim Negadaylov |
Created | 2011-06-06T05:46:23.000+0000 |
Updated | 2017-03-03T23:34:43.000+0000 |
Description
When trying to get location data by using getCurrentPosition method of Ti.Geolocation module the error occurs: The operation couldn't be completed. (kCLErrorDomain error 0.) code 2
var win = Titanium.UI.currentWindow;
win.backgroundColor = '#fff';
function locationCallback(e){
if (!e.success || e.error) {
l.text = 'error: ' + e.error + ' code ' + e.code
return;
}
var longitude = e.coords.longitude;
var latitude = e.coords.latitude;
var altitude = e.coords.altitude;
var heading = e.coords.heading;
var accuracy = e.coords.accuracy;
var speed = e.coords.speed;
var timestamp = e.coords.timestamp;
var altitudeAccuracy = e.coords.altitudeAccuracy;
l.text = ' long: ' + longitude + '\n lat: ' + latitude + '\n alt: ' + altitude + '\n heading: ' + heading + '\n accuracy: ' + accuracy + '\n speed: ' + speed + '\n timestamp: ' + timestamp + '\n altitude accuracy: ' + altitudeAccuracy;
}
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
var l = Ti.UI.createLabel({
font:{fontSize:14},
color:'#000',
top:10,
left:10,
height:190,
width:300
});
Ti.UI.currentWindow.add(l);
var currentPosButton = Ti.UI.createButton({
title:'Get Current Position',
height:40,
top:200,
left:10,
width:300,
font:{fontSize:20}
});
Ti.UI.currentWindow.add(currentPosButton);
currentPosButton.addEventListener('click', function() {
l.text = '';
Titanium.Geolocation.getCurrentPosition(locationCallback);
});
Closing ticket as MobileWeb is no longer supported.