The Windows Phone 8 emulator has a little toolbar on the top right. The bottom button is a double chevron (like ">>") - if you click it it brings up "Additional Tools", and one of the tabs is "Location". You can double-click on the map to set your location in the emulator, and you can also record and play back a travelled route.
Windows Phone 8 Geolocator returns fake location on emulator
-
02-12-2021 - |
質問
I've tried to show my location in xaml windows phone 8 app. But always when I try to find my current location I get the fake microsoft location, even with the default maps app. For example, this code above always return same latitude and longitude:
Geolocator locator = new Geolocator();
locator.DesiredAccuracy = PositionAccuracy.High;
Geoposition position = await locator.GetGeopositionAsync();
LatitudeValue.Text = position.Coordinate.Latitude.ToString("0.00");
LongitudeValue.Text = position.Coordinate.Longitude.ToString("0.00");
解決
他のヒント
If I add a pushpin to the map and then call the
await locator.GetGeopositionAsync();
It always returns the coordinates of Microsoft (47.643318, -122.141937), no matter which current location I chose.
It looks like a bug or am I missing something? Is there someone else experiencing this?
Regarding the Microsoft HQ location bug, there is a work around.
If you set:
geoLocator = new Geolocator
{
DesiredAccuracy = PositionAccuracy.High
};
It will show the location you setup in the emulator additional tools.
The emulator always returns a fake location. As mentioned by gregstoll you can control which "fake" location it should be reporting. There's no way to get the true location using the built-in APIs.