HTML and CSS Reference
In-Depth Information
FIGURE 12-16 The Settings page where the user can enable or revoke location permission to the application.
Making use of geolocation data
Geolocation data are quite sensitive, because a user's location can—potentially—reveal where a given
individual is at a given time to the entire world. Location is certainly a matter of privacy, but it is also
a matter of marketing. For both reasons, Windows 8—as well as other mobile operating systems and
web browsers—tends to leave the decision to make location data available up to the user.
As a developer, what a geolocation API generally gives you is a series of numbers that represent
latitude and longitude. While latitude and longitude uniquely identify a specific location in the world,
they are not always useful to applications. To make them useful, you often need to convert the raw
numbers into more human-friendly geographical data, such as city and country?
Adding the Bing SDK to the application
According to the Windows 8 documentation, the object you receive from the call to
getGeopositionAsync should also contain a property of type CivicAddress . As the name implies,
this data type is expected to share accurate information about the street, city, and country that
corresponds to the pair of latitude and longitude values. However, if you read the documentation
carefully and thoroughly, you will also discover that Windows 8 doesn't install any module that
can map a geoposition to a civic address. This means that the following code won't throw any
exception—but it also fails to give you meaningful data.
document.getElementById("address").innerHTML = location.civicAddress.country;
It turns out that to map latitude and longitude to a civic address (if such an address exists), you
need to reference the Microsoft Bing SDK from your project. A reference to the Bing SDK will also be
Search WWH ::




Custom Search