# Once

## once

Adds a one-time listener for an initial occurrence of a specific event on a given layer.

```javascript
mapInstance.once(type, layerId, listener);
```

### Parameter

{% hint style="info" %}
Parameters for "once" is same as "on" or "off" function.
{% endhint %}

{% content-ref url="/pages/-MLBq0psqTwaCUghrUDG" %}
[On/Off](/fatos-api/map/map-control/on-off.md)
{% endcontent-ref %}

#### Example(Javascript + HTML)

```javascript
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Map Event</title>
</head>
<body>
<div style="height: 100vh">
    <div id="app"></div>
    <pre id="info"></pre>
</div>
<button style="position: absolute; float: top; top: 50px; left: 50px;" onclick="mapClick()">Once map Click</button>
<style>
    #info {
        display: block; position: absolute; float: top; top: 0; left: 30%;
        width: 50%; padding: 10px; border: none; border-radius: 3px; font-size: 12px;
        text-align: center; color: #222; background: #fff;
    }
</style>
<script type="text/javascript" src="https://maps.fatos.biz/dist/fatosmap-gl.js"></script>
<script>
    let LatLng = {lat: 37.482901, lng: 126.896038};
    let mapInstance = new fatosmap.maps.Map(
        document.getElementById("app"),
        {
            zoom: 14.5,
            center: LatLng,
            maxZoom: 20,
            minZoom: 2,
            key: 'YOUR_API_KEY',
        }
    );
    function mapClick() {
        mapInstance.once('click', clickEvent);
    }
    function clickEvent(e) {
        console.log('click', e);
        document.getElementById('info').innerHTML = JSON.stringify(e.lngLat);
    }
</script>
</body>
</html>
```


---

# 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://nostramap-doc.fatos.biz/fatos-api/map/map-control/once.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.
