# Geolocation

Namespace: **Wisej.Ext.Geolocation**

Assembly: **Wisej.Ext.Geolocation** (3.2.0.0)

* [Component](https://docs.wisej.com/api?q=wisej.base.component)
  * [Geolocation](/extensions/extensions/geolocation/api/wisej.ext.geolocation.geolocation.md)

The Geolocation component represents an object able to programmatically obtain the position of the device.

{% tabs %}
{% tab title="C#" %}

```csharp
public class Geolocation : Component, IComponent
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class Geolocation
    Inherits Component
    Implements IComponent
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/-MirBsnmjWIxMsN8l0Ms)Geolocation()

Initializes a new instance of the [Geolocation](/extensions/extensions/geolocation/api/wisej.ext.geolocation.geolocation.md) class.

### ![](/files/-MirBsnmjWIxMsN8l0Ms)Geolocation(container)

Initializes a new instance of the [Geolocation](/extensions/extensions/geolocation/api/wisej.ext.geolocation.geolocation.md) class together with the specified container.

| Name          | Type                                                                                       | Description                                                                                                                                   |
| ------------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
| **container** | [IContainer](https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.icontainer) | A [IContainer](https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.icontainer) that represents the container for the component. |

## Properties

### ![](/files/-MirBsnmjWIxMsN8l0Ms)ActiveWatch

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Enables or disables active watch mode for this geolocation component. When enabled, the [PositionChanged](https://docs.wisej.com/api?q=wisej.ext.geolocation.positionchanged) event be fired automatically each time the position of the device changes. (Default: `False`)

### ![](/files/-MirBsnmjWIxMsN8l0Ms)EnableHighAccuracy

[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean): Indicates the application would like to receive the best possible results. (Default: `False`)

If true and if the device is able to provide a more accurate position, it will do so. Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example). On the other hand, if false, the device can take the liberty to save resources by responding more quickly and/or using less power.

### ![](/files/-MirBsnmjWIxMsN8l0Ms)LastPosition

[Position](https://docs.wisej.com/api?q=wisej.ext.geolocation.position): Returns the last position detected by the device.

### ![](/files/-MirBsnmjWIxMsN8l0Ms)MaximumAge

[Int64](https://docs.microsoft.com/en-us/dotnet/api/system.int64): Indicates the maximum age in milliseconds of a possible cached position that is acceptable to return. (Default: `-1`)

If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position. If set to -1 the device must return a cached position regardless of its age.

### ![](/files/-MirBsnmjWIxMsN8l0Ms)Timeout

[Int64](https://docs.microsoft.com/en-us/dotnet/api/system.int64): Sets or gets the maximum length of time (in milliseconds) the device is allowed to take in order to return a position. (Default: `-1`)

## Methods

### ![](/files/-MirBsnmjWIxMsN8l0Ms)GetCurrentPosition(callback)

Returns the current position of the device.

| Parameter    | Type                                                                           | Description |
| ------------ | ------------------------------------------------------------------------------ | ----------- |
| **callback** | [Action\<Position>](https://docs.microsoft.com/en-us/dotnet/api/system.action) |             |

### ![](/files/-MirBsnmjWIxMsN8l0Ms)GetCurrentPositionAsync()

Asynchronously returns the current position of the device.

**Returns:** [Task\<Position>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task).

## Events

### ![](/files/-MirBsnmjWIxMsN8l0Ms)PositionChanged

[EventHandler](https://docs.microsoft.com/en-us/dotnet/api/system.eventhandler) Fired when the location of the browser changes while this component has an active watch.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/extensions/extensions/geolocation/api/wisej.ext.geolocation.geolocation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
