Golf app accuracy off but


I have a little hobby project, where ai am building a Golf App for a 9 holes golf course at my club, So far it's working ok. The only problem i have is the accuracy of the readings. when i use the app by it is up to 100 of meters off :frowning: But when i run Google maps or the Gps test app,in the background, I get a much better accuracy, as good as 2 meters, so it's not my devices gps sensor, phone is a Pixel 7 Pro.
I guess it's something software related.

Here is the aia:
Bullermand (1).aia (21.7 KB)


Hello Barnabas

I think a map expert needs to take a look at this, but an observation - 'Location Changed' is probably not appropriate since you are moving most of the time - just an Update button when you want to see the values would do the job? Or perhaps a Clock Timer with an interval of a minute or so?

The sensor List of Available Providers - have you tried switching provider?

Suggest you try setting Provider to gps When you set the gps, immediately LockProvider when using devices >Android11 (as is your Pixel)

Also, I suspect using the green Lat/Lon blocks might introduce issues. You might have better results using the orange Lat/Lon block in the LocationChanged event.
I suspect that these use different values since Google introduced the fused Provider.

Edit: preliminary tests indicates these yield the same values. :astonished:
Keep in mind the MIT Location sensor probably uses only the US satellite constellations when determining location. Google Maps uses multiple constellations that might improve their reported location precision. It might be time for MIT to consider updating the satellites it can use to obtain a satellite fix. :cry:

Make sure you set Screen1.AskForPermission to Permission FineLocation.

There is a bug in the DistanceToLineString and there may be an issue with DistanceToPoint, see Distance on Map point point and point to line not equal - #3 by SteveJG .

I don't understand your code placing ALL the hole distance Blocks in the LocationChanged event so I agree with @ChrisWard that is a possible issue.

1 Like

Thanks for the help Guy's @ChrisWard & @SteveJG

I sat the Provider to gps, the Provider Locked to true and the permission to FineLocation

I got it down to under 5 meters, indoors, I will be testing on the golf course tomorrow.

I am all new to this so if the blocks arrangement is wacky or you have tips, on doing the blocks simpler or more optimized, I am open to any suggestions and tips :slight_smile:


Dear @Barnabas,
I've seen that the solution has been already given, but since you ask for further optimizations, I can suggest you two hiints.
FIrst, to set the LocationSensor Distance to 0, This means that the minimum distance to raise a new LocationChanged event is 0, and therefore the speed at which the GPS is responding, is not filtered by a certain amount of meters: in other words, the GPS doesn't wait that the distance bwetween two fixes is greater than "x" meters to issue the event.
Second, is to set the TimeInterval to 1000 (milliseconds). In this case the GPS can respond as fast as possible. With these settings I can monitor the speed and the position of a car running > 100Km/H.
Honestly the real speed of your GPS can vary (and depends) on the hardware fitted into the device on which the app is running, and if you are "open-air", but, at least, with these settings you can obtain the fastest response time.
Lastly: these settings can lead to a higher battery consumption, but it's up to you to choose the best compromise between a "real time (and high accuracy)" response, or battery savings.
Best wishes.

Edit : I have also a third hint. Whenever the "Changed" event is raised, you can check the LocationSensor Accuracy before getting the corresponding Lat & Lon (or speed) into your computations (for example 0 <Accuracy< 20). This is particularly useful when the GPS is starting to fix the satellites or whenever it looses the satellites and it is trying to find them again.

No more hints....:slight_smile:


I am at the golf course writing this. Have just been out testing 3 holes. The precision is great far beyond my expectations. The best reading vas 2 meters off and worst just under 3 meters, so I am very pleased :slightly_smiling_face:

Now I have something that works well enough, so I can focus on implementing other stuff, and polish the app🙂

The end result should end up on my watch, i have tested if it was possible to make it work on Android Wear, and it did.

Thanks again guys :+1:


Hi Tommy

Is that using your original code?

Also, I imagine that the GUI you designed for a phone is not going to fit a watch that well........

Yes, its original code + the

The plan is that the individual holes get their own screen/page.

I have tested it by making a app where the result is centered, and it worked well, but we will se :slightly_smiling_face:


You can only see one Screen at a time, so you only need one screen - just change what it displays.

Try something like this, single screen, single button:

Bullermand_Edit.aia (21.3 KB)

Edit: As per Steve's note, Provider Name "GPS" is incorrect, changed to "gps".

1 Like


I like the idea. It seam like the accuracy get less precise, about 70% worse.
I think the GPS needs to be updated all the time.
I know it probably means that the battery life would suffer, but I can live with that, for now, anyway :slight_smile:

In Chris' example unfortunately ProviderName to GPS is incorrect, this MUST be gps (all lower case) . Possibly why 'It seam like the accuracy get less precise,'

If you request GPS your app defaults to fused and you do not want that.

Updating TimeInterval every 20000 ms is more than sufficient.

So guys have been working on the app. I tested this version on my Samsung Galaxy watch 5 pro and it runs and shows the distance to the green.
I forgot that the distance has to update in real-time, I was so focused on getting it precise that I forgot it needed to update in real-time or it would be a crappy rangefinder :slight_smile:
I will test it on the golf course tomorrow, it is still in alpha.
Thanks again for any help!

Here is the new version:

BullermandGPS.aia (50.8 KB)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.