Пример местоположения из nativescript vue не обновляется - PullRequest
0 голосов
/ 13 марта 2020

Вкл. https://play.nativescript.org/ - это компонент, называемый Location, при использовании его внутри HelloWorld. vue выглядит так, как показано ниже, но местоположение не меняется / обновляется при перемещении по моему дому и ожидание или повторное нажатие кнопки Show location. Я установил desiredAccuracy и updateDistance на 1 метр, но также попробовал его со значением Accuracy.high после импорта модуля. В чем может быть проблема?

<template>
    <Page>
        <ActionBar title="Home" />
        <ScrollView>

            <StackLayout>
                <Button text="Show location" @tap="enableLocationServices"/>
                <StackLayout>
                    <Label :text="'Latitude: ' + currentGeoLocation.latitude" />
                    <Label :text="'Longitude: ' + currentGeoLocation.longitude" />
                    <Label :text="'Altitude: ' + currentGeoLocation.altitude" />
                    <Label :text="'Direction: ' + currentGeoLocation.direction" />
                </StackLayout>
            </StackLayout>

        </ScrollView>
    </Page>
</template>

<script>
    const geoLocation = require("nativescript-geolocation");

    export default {
        methods: {
            enableLocationServices: function() {
                geoLocation.isEnabled().then(enabled => {
                    if (!enabled) {
                        geoLocation
                            .enableLocationRequest()
                            .then(() => this.showLocation());
                    } else {
                        this.showLocation();
                    }
                });
            },

            showLocation: function() {
                geoLocation.watchLocation(
                    location => { this.currentGeoLocation = location; },
                    error => { alert(error); }, 
                    {
                        desiredAccuracy: 1,
                        updateDistance: 1,
                        minimumUpdateTime: 1000 * 1
                    }
                );
            }
        },

        data() {
            return {
                currentGeoLocation: {
                    latitude: null,
                    longitude: null,
                    altitude: null,
                    direction: null
                }
            };
        }
    };
</script>
...