TomTom Maps for JavaScript
    Preparing search index...

    Type Alias SetEventStateOptions

    SetEventStateOptions: ByIdOrIndex & {
        mode?: "put" | "add";
        show?: boolean;
        state: EventType;
    }

    Parameters to update the event state of a feature programmatically.

    Use it for:

    • Programmatic selection/highlighting
    • Keyboard navigation
    • External state synchronization
    • Testing and automation

    Type Declaration

    • Optionalmode?: "put" | "add"

      Whether to replace or add to existing event states.

      • put: Sets the event state on this feature and removes it from all others (default)
      • add: Sets the event state on this feature and keeps the states on other features
      'put'
      
      // Exclusive selection (only one can be clicked at a time)
      mode: 'put'

      // Multiple selection (keep existing selections)
      mode: 'add'
    • Optionalshow?: boolean

      Whether to show the feature after updating the event state.

      Set it to false only to make several state changes before rendering. This can speed up batch updates.

      true
      
      // Update and render immediately
      show: true

      // Update without rendering (for batch operations)
      show: false
    • state: EventType

      The event state to set.

      Can be any EventType: 'click', 'contextmenu', 'hover', 'hover-move' or 'long-hover'.

    // Select a feature programmatically
    const options: SetEventStateOptions = {
    index: 0,
    state: 'click',
    mode: 'put', // Remove click state from other features
    show: true
    };

    // Add hover state without affecting others
    const hoverOptions: SetEventStateOptions = {
    index: 2,
    state: 'hover',
    mode: 'add', // Keep other hover states
    show: true
    };