FIMViz.jsAPI
    Preparing search index...

    Function createRegionDraw

    • Mount a modal selection tool over fim.

      Do not start() while the camera is moving. fit()/fitBounds are animated on both providers, and a click resolved mid-animation lands at the pre-animation projection — off by exactly 2× when the fit changed zoom by one level. Await the map first:

      layer.fit();
      await fim.whenIdle(); // resolves immediately-ish when the map is already still
      regionDraw.start();

      This module cannot enforce that itself: it is headless by design (it knows only fim's own methods, never a map SDK), so the wait belongs to the caller that moved the camera.

      Event types the host must enable. polygon and rectangle need only click; rectangle additionally uses hover for its rubber band. freehand and brush prefer mousedown/mouseup, so enable them:

      fim.enableMapEvents(["click", "hover", "mousedown", "mouseup"]);
      

      Without those two, the drag modes fall back to click-to-start / click-to-stop rather than silently doing nothing — which is also how they behave on a touch device that never reports a button press.

      Parameters

      • fim: FimMap
      • Optionalopts: {
            brushRadius?: string | number;
            brushSides?: number;
            freezeCamera?: boolean;
            keys?: boolean;
            keyTarget?: any;
            minSampleMetres?: number;
            mode?: "polygon" | "rectangle" | "freehand" | "brush";
            onCancel?: () => void;
            onComplete?: (
                filter: SpatialFilter,
                points: { lat: number; lng: number }[],
                rings: { lat: number; lng: number }[][],
            ) => void;
            onPoint?: (points: { lat: number; lng: number }[], evt: any) => void;
            onPreview?: (
                rings: { lat: number; lng: number }[][],
                points: { lat: number; lng: number }[],
            ) => void;
        } = {}

      Returns {
          active: boolean;
          cancel: () => void;
          finish: () => SpatialFilter;
          mode: string;
          points: { lat: number; lng: number }[];
          rings: { lat: number; lng: number }[][];
          setMode: (m: string) => void;
          start: () => void;
          undo: () => void;
      }