Titanium 钛地理定位距离筛选器属性未按预期工作

Titanium 钛地理定位距离筛选器属性未按预期工作,titanium,titanium-mobile,appcelerator-titanium,Titanium,Titanium Mobile,Appcelerator Titanium,此处需要地理定位API的帮助-即使在使用Tianium.geolocation.distanceFilter=10之后;10米的回调函数是随机触发的,不会四处移动。你知道这里怎么了吗 function Geolocate() { var self = this; // The callback function we should call when location is finally determined this.locationReceivedCallback

此处需要地理定位API的帮助-即使在使用Tianium.geolocation.distanceFilter=10之后;10米的回调函数是随机触发的,不会四处移动。你知道这里怎么了吗

function Geolocate() {
    var self = this;

    // The callback function we should call when location is finally determined
    this.locationReceivedCallback = function () {};
    // Check if location event is already triggered or not 
    this.isLocationEventRegister = false;
    // The function that unregisters the location event
    this.unregisterLocationEvent = function () {
        this.isLocationEventRegister = false;
        Ti.Geolocation.removeEventListener('location', self.locationReceivedCallback);
    };
}

Geolocate.prototype.init = function () {
    // Setting up some preference values

    Titanium.Geolocation.distanceFilter = 10; //The minimum change of position (in meters) before a 'location' event is fired.

    if (deviceDetect.isIos()) {
        Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST; // Using this value on Android enables legacy mode operation, which is not recommended.

    } else {
        Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_LOW; //Using this value on Android enables simple mode operation.
    }
};

Geolocate.prototype.getCurrentPosition = function (callback) {
    this.isLocationEventRegister = true;
    this.locationReceivedCallback = callback;
    Titanium.Geolocation.addEventListener("location", this.locationReceivedCallback);
};

Geolocate.prototype.locationServicesAreAvailable = function () {
    if (Titanium.Geolocation.locationServicesEnabled) {
        return true;
    } else {
        return false;
    }
};

Geolocate.prototype.cancelLocationRequest = function () {
    this.unregisterLocationEvent();
};

module.exports = Geolocate;


实际情况是,每当我点击GetLocation时,它就会给我当前的位置。然后我试着把它拖到地图或图像视图中最近的地方。突然,我的视线转到了当前位置。这是因为回电话吗?如何摆脱这个问题?

这与您的代码无关,只是GPS的精度问题

GPS的精度(几乎)永远不会超过10米,这意味着它可以在10米之外。当它重新计算你的位置时,它可能在直线下10米处,因此即使你仍然保持完美的GPS精度,你仍然可能有大约10米的差异

这就是说,当你坐在建筑物的电脑后面时,你可能没有最好的GPS精度,你可能有接近30-45米的精度。这意味着每一次重新计算都可能有10米的不同

您的解决方案实际上是在使用此属性的基础上设置费率限制。该属性将确保它不会每秒触发多次,然后您可以在自己的代码中对其进行速率限制