GPS - Lat and Long

Actually, it not works for me too. I have tried to ask permission too. below is the code for ask location permissions. it enabled but still gives me a location unavailable error.

You need to add the below privilege to the config file using the privileges tab first.

http://tizen.org/privilege/location

Then handle your permission ask flow as below.

// use to ask permission for the location
function findLocation(askPermission) {
	
	var permisson_status = tizen.ppm.checkPermission("http://tizen.org/privilege/location");
	
	if (askPermission && permisson_status === 'PPM_ASK') {
		
		tizen.ppm.requestPermission("http://tizen.org/privilege/location", function(e) {
			if (e === 'PPM_DENY_ONCE') {
				
			} else if (e === 'PPM_ALLOW_FOREVER') {
				return callGeoLocationService();
			}
		})
		
	} else if (permisson_status === 'PPM_ALLOW') {
		callGeoLocationService();
	}
}

// call geolocation service
function callGeoLocationService() {
	if (navigator.geolocation) {
		
        navigator.geolocation.getCurrentPosition(
        		locationSuccessCallback, locationErrorCallback,{enableHighAccuracy: true,maximumAge: 0,timeout: 10000}
        );
    } else {
        console.log('Geolocation is not supported.');
    }
}

// when process success
function locationSuccessCallback(position) {
	
    console.log([position.coords.latitude,position.coords.longitude]);
}

// when process error
function locationErrorCallback(error) {
   
    switch (error.code) {
        case error.PERMISSION_DENIED:
            console.log('User denied the request for Geolocation.');
            break;
        case error.POSITION_UNAVAILABLE:
        		console.log('Location information is unavailable.');
            break;
        case error.TIMEOUT:
        		console.log('The request to get user location timed out.');
            break;
        case error.UNKNOWN_ERROR:
        		console.log('An unknown error occurred.');
            break;
    }
}

but unfortunately, my issue was not resolved to enable permissions too. and then I tried to manually enable location permissions from watch settings. not success. hope you will find an answer!

1 Like