FATOS Map Developers (Powered by NostraMap)
Developer SiteConsole
  • FATOS Developer Introduction
  • FATOS API
    • Map
      • Map control
        • Building
        • Bounds
        • Center
        • Heading
        • Flyto
        • Tilt
        • Zoom
        • Marker
          • Instance Members
        • Polyline
        • Polygon
        • Circle
        • On/Off
        • Once
        • Language
        • Theme
        • Cluster
          • Instance Members
      • Button control
      • Utilities
        • Rectangle
        • Distance
        • Area
    • Search
      • POI
      • Address
      • Geocoding
        • Forward
        • Reverse
      • Geofencing
    • Routing
      • Route
      • Route for truck
    • Advanced
      • Logistics
  • FATOS SDK
    • Authentication
    • Platform
      • Android
        • Start
        • Component
      • iOS
        • Start
        • Component
      • React Native
        • Start
        • Component
  • Release note
    • FATOS Map API
    • API Server
    • RP Server
  • Get your API Key
  • Troubleshooting
    • FAQ
Powered by GitBook
On this page
  • once
  • Parameter

Was this helpful?

  1. FATOS API
  2. Map
  3. Map control

Once

Event detection

PreviousOn/OffNextLanguage

Last updated 3 years ago

Was this helpful?

once

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

mapInstance.once(type, layerId, listener);

Parameter

Parameters for "once" is same as "on" or "off" function.

Example(Javascript + HTML)

<!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>
On/Off