Geolocation
The geolocation API aggregates information from a variety of sources to provide an estimated location to your application. The information may come from the Windows Location Provider that uses a combination of Wi-Fi triangulation and IP address data to determine location, or it may come from sources like a built-in GPS device. The API draws on this information to provide the most accurate representation of location available.
Listing 4.6 demonstrates the use of the API to obtain information about the latitude and longitude of the device along with the estimated accuracy of the reading.
Listing 4.6: Obtaining Information About the Device Location
Geoposition pos = await _geolocator.GetGeopositionAsync() .AsTask(token); ScenarioOutput_Latitude.Text = pos.Coordinate.Latitude.ToString(); ScenarioOutput_Longitude.Text = pos.Coordinate.Longitude.ToString(); ScenarioOutput_Accuracy.Text = pos.Coordinate.Accuracy.ToString();
You can learn more about the geolocation API online at http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.geolocation.aspx.