언어 설정

Menu
Sites
Language
GPS Location on Samsung Gear s2, standalone application, is it possible?

Hello,

Is it possible to get the GPS position on a standalone watch app running on the Samsung gear s2?

I have seen this snippet:

https://developer.tizen.org/community/code-snippet/web-code-snippet/get-watch-current-location-web-application

And i have also seen this post:

https://developer.tizen.org/forums/web-application-development/gear-s-gps-location

I can't get the location to work. Im sure i have the privileges on the confix.xml. 

Questions:

1 - Is it possible to get the GPS position on a standalone watch app running on the Samsung gear s2?

2- If so, what steps need to be taken in the watch settings? (connections / Only use GPS is not available on the gear S2) Does anything need to be done in the paired smart phone to share the location?

Thanks,

답변 바로가기

Responses

5 댓글
Juan Ospina

To be more specific, i am trying to get this to work on a Samsung Gear S2 Classic (Bluetooth not 3g/4g)

Seoghyun Kang

Hello,

 

When I watched Samsung site(http://www.samsung.com/in/galaxy/gear-s2/specs/), I found the following information.

"Acc, Gyro, HRM, Barometer, Ambient light, GPS (3G only)"

 

So I think your divice does not support the GPS Sensor. Only 3G model supports the GPS Sensor.

 

Please refer it.

Juan Ospina

Thank you for your reply.

I understand the watch itself has no GPS.

I was wondering though, if it cannot obtain it from the paired watch (without a paired app).

In the weather of the watch i can see that it knows the location so the location is stored somehwere already. 

Mark as answer
Juan Ospina

I'm gonna answer my own question here, because apparently, even though this is the official place to get answers, no one really knows or cares to reply accuretly. 

It is in fact possible to get the location using a Samsung Gear watch S2 (bluetooth model, not the GPS model) running a standalone app.

This works:

(function () {
    var page = document.getElementById("pageLocationFine"),
        resultDiv = document.getElementById("result");

    var options = {
            enableHighAccuracy: true,
            timeout: 5000,
            maximumAge: 0
        },
        id = null;

    function success(pos) {
        var crd = pos.coords;

        resultDiv.innerHTML = ('pos:')
            + ('
              lat: ' + crd.latitude)
            + ('
              lng: ' + crd.longitude)
            + ('
              acc: ' + crd.accuracy + ' meters.');
    }

    function error(err) {
        alert('ERROR(' + err.code + '): ' + err.message + '\n\n' + JSON.stringify(err));
    }

    page.addEventListener("pagebeforeshow", function () {
        id = navigator.geolocation.watchPosition(success, error, options);
    });

    page.addEventListener("pagehide", function () {
        if (id !== null) {
            navigator.geolocation.clearWatch(id);
        }
    });
}());

This also works:

(function () {
    var page = document.getElementById("pageLocationCoarse"),
        resultDiv = document.getElementById("result");


    var options = {
        enableHighAccuracy: false,
        timeout: 5000,
        maximumAge: 0
    };

    function success(pos) {
        var crd = pos.coords;

        resultDiv.innerHTML = ('pos:')
            + ('
lat: ' + crd.latitude)
            + ('
lng: ' + crd.longitude)
            + ('
acc: ' + crd.accuracy + ' meters.');

    }

    function error(err) {
        alert('ERROR(' + err.code + '): ' + err.message + '\n\n' + JSON.stringify(err));
    }

    page.addEventListener("pagebeforeshow", function () {
        navigator.geolocation.getCurrentPosition(success, error, options);
    });

    page.addEventListener("pagehide", function () {
    });
}());

There's a catch though: The watch must be paired and connected at the moment of the request with its paired phone. Otherwise it won't work. This also includes during development beucase, the IDE doesn't allow the watch connecting to the IDE and the phone at the same time.

 

Aziz Bessrour

Hi Juan, can you give us a complete project which contains the geolocalisation. I tested you code but it haven't worked for me.. this is my code :

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="Tizen Wearable Web Basic Template" />

    <title>Tizen Wearable Web Basic Application</title>

    
</head>

<body>
<H1>HERE</H1>
    <div id="main">
	<div id="result"></div>
	</div>
    <script>
    (function () {
        var page = document.getElementById("main"),
            resultDiv = document.getElementById("result");
     
        var options = {
                enableHighAccuracy: true,
                timeout: 5000,
                maximumAge: 0
            },
            id = null;
     
        function success(pos) {
            var crd = pos.coords;
     
            resultDiv.innerHTML = ('pos:')+ ('lat: ' + crd.latitude)+ ('lng: ' + crd.longitude)+ ('acc: ' + crd.accuracy + ' meters.');
        }
     
        function error(err) {
            alert('ERROR(' + err.code + '): ' + err.message + '\n\n' + JSON.stringify(err));
        }
     
        page.addEventListener("pagebeforeshow", function () {
            id = navigator.geolocation.watchPosition(success, error, options);
        });
     
        page.addEventListener("pagehide", function () {
            if (id !== null) {
                navigator.geolocation.clearWatch(id);
            }
        });
    }());
    </script>
    
</body>

</html>