Mappedin JS - v6.14.0
    Preparing search index...

    Interface Labels

    Labels are text elements anchored to map objects that automatically rotate, show/hide based on priority and zoom level, and manage collisions with other labels. They're perfect for displaying location names, points of interest, and contextual information.

    • Automatic collision management and visibility ranking
    • Customizable appearance (color, font, background, etc.)
    • Support for interactivity (click, hover)
    • Automatic rotation and positioning
    • Batch operations for adding all labels at once

    Best Practice: Use the rank option to control label visibility priority. Use interactive: true to enable click/hover events for important labels.

    // Add a single label
    mapView.Labels.add(space, 'Welcome', { appearance: { color: 'blue' } });

    // Add a label with high priority
    mapView.Labels.add(space, 'Main Entrance', { rank: 'always-visible' });

    // Add all labels automatically (experimental)
    mapView.Labels.__EXPERIMENTAL__all();

    // Remove a specific label
    mapView.Labels.remove(label);

    // Remove all labels
    mapView.Labels.removeAll();
    • Use appearance to customize colors, fonts, and backgrounds.
    • Use rank to control collision priority ('low', 'medium', 'high', 'always-visible').
    • Use __EXPERIMENTAL__all() to automatically add labels for all map objects with predefined text (experimental feature).

    This class is accessed using MapView.Labels.

    interface Labels {
        __EXPERIMENTAL__all(options?: TAddLabelOptions): Label[];
        add(target: IAnchorable, text: string, options?: TAddLabelOptions): Label;
        getAll(): Label[];
        remove(label: Label): void;
        removeAll(): Label[];
    }
    Index

    Methods

    • Experimental

      Parameters

      Returns Label[]

      An array of all created Label instances.

      EXPERIMENTAL FEATURE UNDER CONSTRUCTION

      This is an experimental feature that may undergo significant changes, including breaking changes, renaming, or complete removal in future versions. Do not rely on this API in production environments.

      Automatically adds all the labels (Label) to the map.

      The text, appearance, priority, etc. of the labels will be automatically determined based on the external data from the map.

      const labels = mapView.Labels.__EXPERIMENTAL__all();
      
      const labels = mapView.Labels.__EXPERIMENTAL__all({
      appearance: { color: 'darkblue' },
      rank: 'high'
      });
    • Adds a label (Label) to the map.

      Parameters

      Returns Label

      The created label, or undefined if creation failed.

      mapView.Labels.add(space, 'Welcome', { appearance: { color: 'blue' } });
      
      mapView.Labels.add(space, 'Main Entrance', {
      rank: 'always-visible',
      interactive: true,
      appearance: {
      color: 'red',
      backgroundColor: 'white',
      fontSize: 14
      }
      });
    • Removes a label (Label) from the map.

      Parameters

      • label: Label

        The label which should be removed.

      Returns void

      mapView.Labels.remove(label);
      
    • Removes all the labels (Label) from the map.

      Returns Label[]

      An array of all removed Label instances.

      const removedLabels = mapView.Labels.removeAll();