Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5503] MobileWeb: Error occurs when using getCurrentPosition method of Ti.Geolocation module in iPhone

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-06-08T01:45:40.000+0000
Affected Version/sn/a
Fix Version/sBacklog
ComponentsMobileWeb
Labelsn/a
ReporterMisha Vasko
AssigneeMaxim Negadaylov
Created2011-06-06T05:46:23.000+0000
Updated2017-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);

});

Comments

  1. Lee Morris 2017-03-03

    Closing ticket as MobileWeb is no longer supported.

JSON Source