HTML5 GeoLocation-Geolocation watchPosition() API - HTML 5

What is the use of Geolocation watchPosition() API?

Description

WatchPosition method is used to retrieve periodic updates of the current geographic location of the device and the location is expressed as a set of geographic coordinates along with heading and speed. Location information is returned in a Position object and each update returns a new Position object.

Syntax

Below is the syntax of this method

watchPosition(showLocation, ErrorHandler, options);

Parameters

Detail of parameters are given below

  • showLocation − showLocation is called asynchronously with an object corresponding to the Position object used for storing the returned location information and describes a callback method for retrieving the location information.
  • ErrorHandler − ErrorHandler is an optional parameter called with the PositionError object that stores the returned error information and is used to specify the callback method invoked when an error occurs while processing the asynchronous call.
  • options − options is an optional parameter used to specify a set of options to retrieve the location information. 3 options can be specified such as (a) Accuracy of the returned location information (b) Timeout for retrieving the location information and (c) Use of cached location information.

Return value

WatchPosition method returns a unique transaction ID (number) associated with the asynchronous call. This ID can be used to cancel the watchPosition call and to stop receiving location updates.

Example

Output

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

HTML 5 Topics