W 3C Geolocation API
Michael(tm) Smith mike@w3.org
W 3C Geolocation API Michael ( tm ) Smith mike@w3 . org Overview - - PowerPoint PPT Presentation
W 3C Geolocation API Michael ( tm ) Smith mike@w3 . org Overview API for use in W eb applications ( through JavaScript binding ) enables Web application running on a remote server to access user location ( latitude / longitude ) data ; e
Michael(tm) Smith mike@w3.org
Overview
(through JavaScript binding)
remote server to access user location (latitude/longitude) data; e.g., for a user accessing the Web from a browser running on a mobile device (mobile handset, laptop, etc.)
How does a W eb app get access to user location data?
The API requires browser support ; either the device a browser is running on must directly expose one or more location- sensing mechanisms (e.g., GPS) to the browser, or some other third- party application must expose it to the browser (e.g., WiFi positioning through SkyHook)
W ho’ s doing the work?
with support for the API
W here to get it
http://dev.w3.org/geo/api/spec- source.html
Requirem ents
a pair of latitude and longitude coordinates
accuracy of the retrieved location data
shot" position updates
Requirem ents (m ore)
to receive repeated position updates
query the last known position
to receive updates about errors that may have occurred while obtaining a location fix
Requirem ents (m ore)
desired accuracy level of the location information
sources of location inform ation
address information as part of the location data
Agnostic about location m ethod
any particular location method.
sensing m echanism exposed to the browser; might be on GPS, IP address, RFID, WiFi, Bluetooth MAC address, GSM/ CDMA cell IDs,…
Som e use cases
area
by- turn route navigation (like NaviTim e)
in the user's vicinity
tagged status updates in social networking applications
Exam ple: “ One- shot” query
function showMap(position) { // Show a map centered at // at (position.latitude, position.longitude). } // One- shot position request. navi gat or .geol ocat i on.get Cur r ent Posi t i on(showMap);
Exam ple: Position updates
function scrollMap(position) { // Scrolls the map so it is centered // at (position.latitude, position.longitude). } // Request repeated updates. var watchId = navi gat or .geol ocat i on.w at chPosi t i on(scrollMap); function buttonClickHandler() { // Cancel when user clicks button navi gat or .geol ocat i on.cl ear W at ch(watchId); }
IDL: Geolocation interface
interface G eol ocat i on { readonly attribute Position l ast Posi t i on; void getCurrentPosition(in Posi t i onCal l back successCallback); … int watchPosition(in Posi t i onCal l back successCallback); … void clearWatch(in int watchId); };
IDL: PositionCallback interface
interface Posi t i onCal l back { void handleEvent(in Posi t i on position); };
IDL: Position object
interface Posi t i on { readonly attribute double l at i t ude; readonly attribute double l ongi t ude; readonly attribute double accur acy; readonly attribute double altitude; readonly attribute double altitudeAccuracy; readonly attribute double heading readonly attribute double velocity readonly attribute DOMTimeStamp timestamp; };
The End
Thanks! mike@w3.org