GPS - Lat and Long

How do I get the location (lat and long) on webapp?

Ps.: navigator.geolocation throws error… and I didnt find any doc about the GPS itself…

Thank you for your time!

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

Hello, I already solved this problem using the tizen “healthinfo” API.

Thank you!

1 Like

can you please provide a link of it?

https://docs.tizen.org/application/web/api/5.0/device_api/wearable/tizen/humanactivitymonitor.html#HumanActivityGPSInfo

1 Like

Thank you very much for the support!

1 Like

check this Tizen location infromation unavailable - #2 by andrzej_bugajny

1 Like

You can use Tizen Human Activity Monitor (HAM) API or W3C Geolocation API

https://docs.tizen.org/application/web/guides/sensors/ham/

https://docs.tizen.org/application/web/guides/w3c/location/geolocation/

For both cases, please make sure location privilege is added on config.xml.

1 Like