开发者

Titanium Mobile is not getting correct accuracy on iOS

I have a problem with my coding. My code just doesn't seem to be getting an accuracy lower then 1414.

Whenever I open google maps, and get my location there it finds it usually within a second. If I switch back I see a correct accuracy for a couple of seconds, and then it switches back to the very low accuracy (1414).

What am I doing wrong?

This is my code:

function reportPosition(e){
    label.text = e.coords.longitude + " - " + e.coords.accuracy;
}

Ti.Geolocation.purpose = "Test";
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.distanceFilter = 10;
Ti.Geolocation.preferredProvider = Titanium.Geolocation.PROVIDER_GPS;
Titanium.Geolocation.getCurrentPosition(reportPosition);

Titanium.Geolocation.addEventListener('location', reportPosition);
Titanium.Geolocation.addEv开发者_StackOverflow中文版entListener('heading', reportPosition);


Do you have any more context for this question?

I have ran your exact code and received accuracy of between 10 and 183 but never any higher.

I also split it up to make sure that 'heading' wasn't calling the same method reporting bogus numbers.

I compiled against 4.1 with Ti 1.7.2 on both my simulator and iPhone 4S.

Do you have compass interference turned off? When you say you switch from google maps to your app. Are you switching or are you using an embedded map? I tried switching between maps and my app with no major change to the accuracy?

Possibly bad hardware or location? (Although that wouldn't explain why you get good results after using google maps). Do you get good results always at the start of your app and they degrade?

The obvious answer would be that you are doing nothing wrong and that you are receiving the correct level of accuracy for the location/hardware where you are using it.


I had the same issue and discovered that there must be some issue with ACCURACY_BEST option.

Is weird but trying with a worse accuracy option gives me better results, just try something like this:

Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_NEAREST_TEN_METERS;

What I did then is to start with ACCURACY_NEAREST_TEN_METERS and then change it later to ACCURACY_BEST (in the first location reading).

Tried this at different locations and it starts with 65meters on first readings and goes to 10 - 5 meters later.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜