Options
All
  • Public
  • Public/Protected
  • All
Menu

Mouse controller that allows visual comparison of multiple collections of layers by quickly toggling their visibility. Doing so allows easy verification of differences in the layer contents.

Flickering is done by (quickly) clicking the mouse button. The default behavior will increment the visibleIndex on every mouse click.

FlickerController usage
FlickerController in action

Usage:

import {FlickerController} from "@luciad/ria/view/controller/FlickerController";

const flickerController = new FlickerController();
map.controller = flickerController;

// the SampleFlickerUI allows the user to select layers, but you can also do it programmatically
const flickerLayers1 = [blackMarbleLayer];
const flickerLayers2 = [globalImageryLayer];
flickerController.layers = [flickerLayers1, flickerLayers2];

Note that you can only use a FlickerController on a WebGLMap.

The FlickerController provides no out-of-the-box UI. You can use the sample UI implementation from samples/common/controllers/ui/SampleFlickerUI as-is. It can be re-styled using CSS variables. You can also use it as a reference to create your own UI on top of the FlickerController API.

You can customize the controller to respond to keyboard events as follows:

import {HandleEventResult} from "@luciad/ria/view/controller/HandleEventResult";
import {KeyEvent} from "@luciad/ria/view/input/KeyEvent";
import {KeyEventType} from "@luciad/ria/view/input/KeyEventType";
import {FlickerController} from "@luciad/ria/view/controller/FlickerController";

/**
 * A FlickerController that flickers when the user presses space bar
 */
class KeyboardFlickerController extends FlickerController {

  constructor() {
    super();
  }

  onKeyEvent(keyEvent: KeyEvent): HandleEventResult {
    if (keyEvent.type === KeyEventType.DOWN && keyEvent.domEvent?.key === " " /* space bar */) {
      this.visibleIndex = (this.visibleIndex + 1) % this.layers.length;
      return HandleEventResult.EVENT_HANDLED;
    }
    return HandleEventResult.EVENT_IGNORED;
  }

}

map.controller = new KeyboardFlickerController();
since

2021.0

Hierarchy

Implements

Overview

Constructors

constructor

Events

on

  • (event: "LayersChange", callback: (layers: Layer[][]) => void): Handle
  • (event: "VisibleIndexChange", callback: (index: number) => void): Handle
  • (event: "Invalidated", callback: () => void): Handle
  • (event: "Activated", callback: (map: Map) => void): Handle
  • (event: "Deactivated", callback: (map: Map) => void): Handle

Accessors

layers

  • get layers(): Layer[][]
  • set layers(val: Layer[][]): void
  • Sets the layers to use. When started, only the first set of layers is visible and the others are made invisible. When calling visibleIndex, the layer collection at the given index is made visible, and the others are made invisible.

    Layers that are not mentioned in any of the layer sets, are always visible.

    If you want to flicker just one layer, put the one layer in its own layer set, and leave the other layer set empty.

    flickerController.layers = [[layerToFlicker], []];

    Returns Layer[][]

  • Sets the layers to use. When started, only the first set of layers is visible and the others are made invisible. When calling visibleIndex, the layer collection at the given index is made visible, and the others are made invisible.

    Layers that are not mentioned in any of the layer sets, are always visible.

    If you want to flicker just one layer, put the one layer in its own layer set, and leave the other layer set empty.

    flickerController.layers = [[layerToFlicker], []];

    Parameters

    Returns any

map

  • get map(): Map | null
  • set map(_value: Map | null): void
  • The map on which this controller is currently active or null if this controller is not currently active. This property is read-only.

    Returns Map | null

  • The map on which this controller is currently active or null if this controller is not currently active. This property is read-only.

    Parameters

    • _value: Map | null

    Returns any

visibleIndex

  • get visibleIndex(): number
  • set visibleIndex(index: number): void
  • Returns the index of the layer collection that is visible.

    Returns number

  • Sets the collection of layers with the given index visible, making the layers in the other collections invisible.

    Parameters

    • index: number

      the index of the visible layers

    Returns any

Methods

invalidate

  • (): void

onActivate

  • (map: Map): void

onDeactivate

  • (map: Map): Promise<any> | any

onDraw

  • Callback that allows controller implementations to perform custom drawing on the map. Controller shapes and icons are drawn on top of all other content in the map. Note that the map may perform caching which may cause this method to only be invoked once. When a controller implementation's appearance changes the implementation should call invalidate on itself.

    Parameters

    • geoCanvas: GeoCanvas

      the GeoCanvas on which the controller can draw shapes.

    Returns void

onDrawLabel

  • Callback that allows controller implementations to draw labels on the map. Note that the map may perform caching which may cause this method to only be invoked once. When a controller implementation's appearance changes the implementation should call invalidate on itself.

    Parameters

    • labelCanvas: LabelCanvas

      the LabelCanvas on which the controller can draw labels.

    Returns void

onGestureEvent

onKeyEvent

  • Called when a key event has been received. This method must return a HandleEventResult value to indicate if the event was handled or not, If this method returns EVENT_IGNORED, the map will be given the opportunity to perform default key event behaviour. If default event handling is not desired, this method should return EVENT_HANDLED. (See the Controller class description for the default behavior.)

    Parameters

    • keyEvent: KeyEvent

      The key event to be handled. Note that this is a KeyEvent and not a DOMEvent. You can access the corresponding DOMEvent through KeyEvent.domEvent.

    Returns HandleEventResult

    The key event handling result.

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method