Search code examples
javascriptgeolocationwatchtizentizen-web-app

(Tizen Web App) Getting the Geo Location doesn't resolve error or success in emulator


Trying to get the geo location for a Tizen Wearable Web Application Emulator.

My flow is:

  1. Check permission

  2. Ask permission if no permission

  3. If I have permission request the geo location

  4. Otherwise die and return error

I've resorted in the example to just outputting to the console.

I've tried requesting the permission, passing a method which just outputs to console.

The code provided is after the Passover from permission with the permission successful.

Permission: http://tizen.org/privilege/location

GeoLocation.prototype.getlastgeolocation2 = function (f_obj)
{
    console.log("HERE");
    if (navigator.geolocation)
    {
        if(!f_obj.maxAge || f_obj.maxAge == null || f_obj.maxAge == 0)
        {
            console.log(1);
            navigator.geolocation.getCurrentPosition(function(position){ console.log("Success");}, function(error){ console.log("Error");},{maximumAge: 60000});
        }
        else
        {
            console.log(2);
            navigator.geolocation.getCurrentPosition(function(position){ console.log("Success");}, function(error){ console.log("Error");},{maximumAge: f_obj.maxAge});
        }
    }
    else
    {
        console.log("No Navigator");
        returnMethod(false,'Geolocation is not supported.');
    }
};

I should get in the console: HERE, 1, Success or Error

I get: HERE, 1

Suggesting the navigator doesn't resolve. No errors in the console nothing.


Solution

  • When working on emulator with GPS features, it is important to remember about 'injecting' the location first.

    To do this, you need to right click on Emulator -> Control Panel -> Location. Then in 'manual' section just enter some values for longitude, latitude etc. At the end click 'Inject Location' button.

    Just after that you should be able to gather the location using above code.