Geolocator.GetGeopositionAsync() return rounded values if regional setting isn't set on "English (United-States)"

152 views Asked by At

I try to use the geolocation function from Windows Phone 8.1, and it works when the emulated Windows Phone has its regional setting on "English (United State)", but my application is targetting mostly French people, and when I try with the regional setting (by default on my computer) "French (France)" the longitude and lattitude values are irrelevant, because they are rounded.

My code:

Geolocator watcher = new Geolocator();
watcher.DesiredAccuracy = PositionAccuracy.High;
Geoposition position = await watcher.GetGeopositionAsync();
double lat = position.Coordinate.Point.Position.Latitude;
double lon = position.Coordinate.Point.Position.Longitude;

With regional setting on "English (United State)", lat and lon get values like "48.12345", when I keep default / "French (France)" regional setting, they get "48.0" (and the values are already incorrects into the watcher object).

I actually tried many thing (I suspect the decimal separator to be guilty maybe the geolocation simulator sent value like "48,12345", but the parsing of these value is out of my scope, into sealed functions). So I tried to change regional format in apps many ways, but nothing works for now.

Someone know a workaround about this? (I found some similar case on the internet with German developers, but I don't really find a solution...)

1

There are 1 answers

0
Fred On BEST ANSWER

Since you pointed out that this problem happens with your emulator and not on an actual phone you should check your system settings.

I also used to have numerous issues with the WP geolocation feature on my dev machines and am now using the "English" standardization of decimal grouping to prevent these problems.

There is an article that explains how to do the setup (which is fairly easy but the downside is that it also affects the display of all numbers on your system such as in Office..):

http://dotnetbyexample.blogspot.de/2014/05/windows-phone-emulatorunable-to-create.html