2014-05-09 48 views
1

我正在研究一个需要用户当前位置的应用程序。getCurrentPosition不更新位置

我面临的一个问题,即第一次设备获取用户当前位置的经纬度并缓存它,并且每次都返回相同的经纬度。有什么办法从设备中删除缓存的位置?任何帮助将不胜感激。

我的一些代码:

Titanium.Geolocation.purpose = "Recieve User Location"; 
Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_BEST; 
Ti.Geolocation.distanceFilter = 5; 
Ti.Geolocation.activityType = Ti.Geolocation.ACTIVITYTYPE_FITNESS; 

Titanium.Geolocation.getCurrentPosition(function(e) 
{ 
    if (!e.success || e.error) 
    { 
     alert('error ' + JSON.stringify(e.error)); 
     return; 
    } 
    else 
    { 
     var longitudeFore; 
     var latitudeFore; 

     longitudeFore = e.coords.longitude; 
     latitudeFore = e.coords.latitude; 

     latitudeFore = parseFloat(latitudeFore); 
     longitudeFore = parseFloat(longitudeFore); 

     latitudeFore = latitudeFore.toFixed(6); 
     longitudeFore = longitudeFore.toFixed(6); 

     alert(latitudeFore + '\n' + longitudeFore); 
    } 
}); 

请有人可以提出一个解决办法?

回答

2

由于您应用了距离过滤器,因此您将永远不会收到当前位置,除非它超过了从兑现位置过滤的距离。获取当前位置的一种方法是去除距离过滤器,或者停止位置服务并重新启动它们,我认为这会为您提供最后一个已知位置。