> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/sdks/sdk-web/componentes/sdk-provider/eventos/geolocationfinish.md). Agents can also search and read this documentation through its [MCP server](https://docs.facephi.com/~gitbook/mcp).

# geolocationFinish

Emits the result of the native geolocation request.

## Details

Emitted once, when the geolocation request initiated by the [geolocation](https://docs.facephi.com/docs.facephi-en/sdks/sdk-web/componentes/sdk-provider/propiedades/geolocation.md) property is resolved. It is not emitted while the property is `DISABLED`.

**Event:** `geolocationFinish`

**Type:** `FacephiSdkProviderCustomEvent<GeolocationResult>` | `CustomEvent<GeolocationResult>`

### Syntax

```typescript
provider.addEventListener('geolocationFinish', onGeolocationFinish);
```

### Received object

```json
detail: {
  status: GeolocationStatus,
  coordinates: {
    latitude: number,
    longitude: number,
    accuracy: number
  } | null
}
```

### GeolocationStatus

| Member        | Value         | Description                                                  |
| ------------- | ------------- | ------------------------------------------------------------ |
| `Success`     | `SUCCESS`     | Location obtained.                                           |
| `Denied`      | `DENIED`      | The user denied location permission.                         |
| `Unavailable` | `UNAVAILABLE` | The browser could not determine the position or timed out.   |
| `Unsupported` | `UNSUPPORTED` | The browser does not expose `navigator.geolocation`.         |
| `Insecure`    | `INSECURE`    | The origin is not a secure context (`https` or `localhost`). |

## Description

Reports the result of the location request, including its status and, when obtained, the user's coordinates.

### Considerations

`coordinates` has a value only when the status is `SUCCESS`. It is `null` for all other statuses.

In `REQUIRED` mode, any status other than `SUCCESS` also triggers the `GeolocationError` ([ error `SDK_139`](https://docs.facephi.com/docs.facephi-en/sdks/sdk-web/componentes/sdk-provider/codigos-de-error.md)) via [emitError](https://docs.facephi.com/docs.facephi-en/sdks/sdk-web/componentes/sdk-provider/eventos/emiterror.md) and stops the flow. In OPTIONAL mode, `OPTIONAL` the flow continues, and this event is the only way to know the result.

***

## Example

```jsx
<facephi-sdk-provider
    apikey={process.env.FACEPHI_SDK_APIKEY}
    geolocation={GeolocationMode.Optional}
    onGeolocationFinish={(event) => {
        const { status, coordinates } = event.detail;
        console.log('GEOLOCATION:', status, coordinates);
    }}
/>
```

```typescript
import { type GeolocationResult, GeolocationStatus } from '@facephi/sdk-web-wc';

provider.addEventListener('geolocationFinish', (event) => {
  const result: GeolocationResult = event.detail;
  if (result.status === GeolocationStatus.Success) {
    console.log(result.coordinates.latitude, result.coordinates.longitude);
  }
});
```
