Table of Contents

Class Geolocation

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The Geolocation interface represents an object able to obtain the position of the device programmatically. It gives Web content access to the location of the device. This allows a website or app to offer customized results based on the user's location.

[Value("Geolocation")]
public class Geolocation
Inheritance
Geolocation
Inherited Members

Remarks

An object with this interface is obtained using the Geolocation property implemented by the Navigator object.

NOTE

For security reasons, when a web page tries to access location information, the user is notified and asked to grant permission. Be aware that each browser has its own policies and methods for requesting this permission.

-Using geolocation

See also on MDN

Constructors

Geolocation()

public Geolocation()

Methods

ClearWatch(long)

The clearWatch() method of the Geolocation interface is used to unregister location/error monitoring handlers previously installed using WatchPosition(PositionCallback, PositionErrorCallback?, PositionOptions).

[Value("clearWatch")]
public GlobalObject.Undefined ClearWatch(long watchId)

Parameters

watchId long

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

GetCurrentPosition(PositionCallback, PositionErrorCallback?, PositionOptions)

The getCurrentPosition() method of the Geolocation interface is used to get the current position of the device.

[Value("getCurrentPosition")]
public GlobalObject.Undefined GetCurrentPosition(PositionCallback successCallback, PositionErrorCallback? errorCallback = null, PositionOptions options = null)

Parameters

successCallback PositionCallback
errorCallback PositionErrorCallback
options PositionOptions

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

Note that in addition to requiring a secure context this feature may be blocked by the geolocation Permissions-Policy, and also requires that explicit permission be granted by the user.
If required, the user will be prompted when this method is called.
The permission state can be queried using the geolocation user permission in the Permissions API.

-Using the Geolocation API
-Geolocation

See also on MDN

WatchPosition(PositionCallback, PositionErrorCallback?, PositionOptions)

The watchPosition() method of the Geolocation interface is used to register a handler function that will be called automatically each time the position of the device changes.
You can also, optionally, specify an error handling callback function.

[Value("watchPosition")]
public long WatchPosition(PositionCallback successCallback, PositionErrorCallback? errorCallback = null, PositionOptions options = null)

Parameters

successCallback PositionCallback
errorCallback PositionErrorCallback
options PositionOptions

Returns

long

An integer ID that identifies the registered handler.
The ID can be passed to the ClearWatch(long) to unregister the handler.

Remarks

Note that in addition to requiring a secure context this feature may be blocked by the geolocation Permissions-Policy, and also requires that explicit permission be granted by the user.
If required, the user will be prompted when this method is called.
The permission state can be queried using the geolocation user permission in the Permissions API.

-Using the Geolocation API
-The interface it belongs to, Geolocation, and the way to access it —
Geolocation.
-The opposite operation: ClearWatch(long)
-A similar method: GetCurrentPosition(PositionCallback, PositionErrorCallback?, PositionOptions)

See also on MDN