Share via


How to Create a Location-Aware Webpage

Support for the Geolocation API first introduced in Windows Internet Explorer 9 enables a web application to access the current geographical location of the computer or device running the browser. The web application can then tailor the user experience according to the location, for instance, to display the user’s position on a map, or display up-to-date local information such as weather or news reports.

In this section

Topic Description

Introduction to the Geolocation API

This topic provides an introduction to the Geolocation API, explains how to determine if Geolocation is supported, and discusses how user privacy is protected.

Getting the Current Location

This topic provides a sample showing how to use the geolocation object’s getCurrentPosition method to get the current location and display it in a webpage.

Watching for Location Changes

A web application might request to continuously listen for location updates, for instance, to scroll a map each time the location changes. This topic provides a sample that uses the geolocation object's watchPosition method to receive location updates each time the position of the computer or device hosting the web application changes.

Handling Errors

This topic provides a sample that demonstrates how to implement a callback function to handle errors that result from calls to the Geolocation API.

Specifying the Time-out Duration

To limit the time allowed for the Geolocation API to determine the location, developers can use the optional options parameter that is passed to getCurrentPosition or watchPosition.

 

Geolocation