Как отобразить широту, долготу, курс в телефонной щели - PullRequest
0 голосов
/ 17 января 2012

Я хочу отобразить широту, долготу, заголовок в том же приложении, используя phonegap.i пробовал phonegap той же программой.*

Ответы [ 2 ]

0 голосов
/ 06 мая 2016
function locationFinder() {
    if (navigator.geolocation) {
        function success(pos) {
            current_lng = pos.coords.longitude;
            current_lat = pos.coords.latitude;
            console.log("longitude get" + current_lng);
            console.log("latitude get" + current_lat);
        }
        function fail(error) {
            console.log("error 2");
        }
        // Find the users current position. Cache the location for 5 minutes,
        // timeout after 6 seconds
        navigator.geolocation.getCurrentPosition(success, fail, {
            maximumAge : 500000,
            enableHighAccuracy : true,
            timeout : 6000
        });
    } else {
        window.plugins.toast.showLongBottom("Please check GPS Setting",
                function(a) {
                    console.log('toast success: ' + a)
                }, function(b) {
                    console.log('toast error: ' + b)
                });
    }
}
0 голосов
/ 17 января 2012

По какой-то причине мне пришлось отслеживать navigator.compass для инициализации в некоторых моих проектах.Иногда он не будет существовать до тех пор, пока не сработает deviceReady.Я обычно использую что-то вроде этого:

var intervalId = setInterval(function() {
   if( navigator.compass ) {
      clearInterval(intervalId);
      intervalId = navigator.compass.watchHeading(onSuccess, onError, options);
   }
}, 250);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...