Skip to content

Configuration

All configuration is passed to GestureMapController at construction time. Every key is optional; unspecified keys use the defaults shown below.

ts
const controller = new GestureMapController({
  map,          // required: your ol/Map instance
  webcam: { ... },   // optional: WebcamConfig
  tuning: { ... },   // optional: TuningConfig
  debug: false,      // optional: boolean
});

WebcamConfig

Controls the webcam video overlay rendered on top of the map.

KeyTypeDefaultDescription
enabledbooleantrueShow or hide the overlay entirely. Set to false to run gesture detection without showing the camera feed.
mode'corner' | 'full' | 'hidden''corner''corner' renders a small picture-in-picture overlay. 'full' fills the map container. 'hidden' hides the video but keeps the canvas skeleton visible.
position'bottom-right' | 'bottom-left' | 'top-right' | 'top-left''bottom-right'Which corner to anchor the overlay when mode === 'corner'.
widthnumber320Overlay width in pixels (corner mode).
heightnumber240Overlay height in pixels (corner mode).
marginnumber16Distance in pixels from the nearest viewport edges.
opacitynumber0.85CSS opacity of the overlay (0 = transparent, 1 = fully opaque).

Example: move overlay to top-left

ts
const controller = new GestureMapController({
  map,
  webcam: {
    position: 'top-left',
    margin: 12,
    opacity: 0.75,
  },
});

TuningConfig

Controls gesture detection sensitivity, smoothing, and timing.

KeyTypeDefaultDescription
panScalenumber2.0Multiplier applied to hand-movement delta before translating to map pixels. Higher values make panning faster.
zoomScalenumber4.0Multiplier applied to the two-hand distance delta before adjusting zoom level. Higher values make zooming faster.
actionDwellMsnumber80Time in milliseconds a gesture must be held before it is confirmed as active. Prevents accidental triggers.
releaseGraceMsnumber150Time in milliseconds the state machine waits before returning to idle after a gesture ends. Prevents flickering.
panDeadzonePxnumber10Minimum hand movement in normalised-coordinate pixels required to register a pan. Filters out hand tremor.
zoomDeadzoneRationumber0.005Minimum fractional change in two-hand distance required to register a zoom step.
smoothingAlphanumber0.5Exponential moving average factor for landmark positions. 0 = maximum smoothing (very slow response), 1 = raw unsmoothed input.
minDetectionConfidencenumber0.65MediaPipe hand detection confidence threshold (0–1). Lower values detect more hands but with more false positives.
minTrackingConfidencenumber0.65MediaPipe hand tracking confidence threshold (0–1).
minPresenceConfidencenumber0.60MediaPipe hand presence confidence threshold (0–1).

Example: tuning for responsiveness

Lower dwell time and dead zone for faster, more immediate response:

ts
const controller = new GestureMapController({
  map,
  tuning: {
    actionDwellMs: 40,      // confirm gestures faster
    releaseGraceMs: 80,     // return to idle faster
    panDeadzonePx: 5,       // react to smaller movements
    panScale: 3.0,          // amplify pan speed
  },
});

Example: tuning for precision

Higher smoothing and dead zones for slow, deliberate control:

ts
const controller = new GestureMapController({
  map,
  tuning: {
    smoothingAlpha: 0.2,     // heavy smoothing, slow but stable
    panDeadzonePx: 20,       // require larger movements
    zoomDeadzoneRatio: 0.01, // require larger zoom gesture
    actionDwellMs: 120,      // require longer hold before confirming
  },
});

Example: debug mode

Logs the active gesture mode to the browser console on every frame:

ts
const controller = new GestureMapController({
  map,
  debug: true,
});