Class: LayerItemView

LayerItemView()

One item in a Layer List: shows some basic information about the Map Asset (Layer), including label and icon. Also has a button that changes the visibility of the Layer of the map (by updating the 'visibility' attribute in the MapAsset model). Clicking on the Layer Item opens the Layer Details panel (by setting the 'selected' attribute to true in the Layer model.)

Screenshot

Constructor

new LayerItemView()

Since:
  • 2.18.0
Source:

Extends

  • Backbone.View

Members

className :string

The HTML classes to use for this view's element
Type:
  • string
Source:

errorMessage :string

The text to show in a tooltip when the MapAsset's status is set to 'error'. If the model also has a 'statusMessage', that will be appended to the end of this error message.
Type:
  • string
Source:

isCategorized :boolean

Whether the layer item is a under a category. Flat layer item and categorized layer item are styled differently.
Type:
  • boolean
Source:

model :MapAsset

The model that this view uses
Type:
Source:

template :Underscore.template

The primary HTML template for this view
Type:
  • Underscore.template
Source:

type :string

The type of View this is
Type:
  • string
Source:

Methods

appendStatusElement(element)

Append a status-related element to the layer label while keeping UI setup centralized.
Parameters:
Name Type Description
element HTMLElement The element to append.
Since:
  • 2.41.0
Source:

events() → {object}

A function that gives the events this view will listen to and the associated function to call.
Source:
Returns:
Returns an object with events in the format 'event selector': 'function'
Type
object

getStatusState() → {object}

Derive the current status state being rendered for this layer.
Since:
  • 2.41.0
Source:
Returns:
State data used by the status UI.
Type
object

initialize(optionsopt)

Executed when a new LayerItemView is created
Parameters:
Name Type Attributes Description
options object <optional>
A literal object with options to pass to the view
Source:

insertFilterIcon()

Insert the filter icon to the right of the label element text. This icon appears for layers that are "filterable" based on their atrributes. Filter attributes for each layer are defined in the map model. Layer items with this icon will have the Filter feature (built using VectorFilterView).
Since:
  • 2.34.0
Source:

insertIcon()

Waits for the icon attribute to be ready in the Map Asset model, then inserts the icon before the label.
Source:

insertStatusIconSlot()

Create the (always-present, fixed-size) slot used to show the loading spinner or error icon next to the label. Kept in the DOM permanently and toggled via visibility so it never changes the label row's layout.
Since:
  • 2.41.0
Source:

removeStatuses()

Remove any icons, tooltips, or other visual indicators of a Map Asset's error or loading status in this view
Source:

render()

Source:
Searches and only displays self if layer label matches the text. Highlights the matched text.
Parameters:
Name Type Attributes Description
text string <optional>
The search text from user input.
Source:
Returns:
- True if a layer label matches the text
Type
boolean

showBadge(text, styleopt)

Create a badge element and insert it to the right of the layer label.
Parameters:
Name Type Attributes Description
text string The text to display in the badge
style string <optional>
The style of the badge. Can be any of the styles defined in the MapConfig#Notification style property, e.g. 'green'
Source:

showError(message)

Indicate to the user that there was a problem showing or loading this error. Shows a 'warning' icon to the right of the label for the asset and a tooltip with more details
Parameters:
Name Type Description
message string The error message to show in the tooltip.
Source:

showLoading()

Show a spinner icon to the right of the Map Asset label to indicate that this layer is loading
Source:

showSelection()

Highlight/emphasize this item in the Layer List when it is selected (i.e. when the Layer model's 'selected' attribute is set to true). If it is not selected, then remove any highlighting. This function is executed whenever the model's 'selected' attribute changes. It can be changed from within this view (with the toggleSelected function), from the parent Layers collection, or from the Layer Details View.
Source:

showStatus()

Gets the Map Asset model's status and updates this Layer Item View to reflect that status to the user.
Source:

showVisibility()

Add or remove styles that indicate that the layer is shown based on what is set in the Layer model's 'visible' attribute. Executed whenever the 'visible' attribute changes.
Source:

toggleFilterIconVisibility()

Turn off the Layer model's 'filter' icon (i.e., set to transparent), if the default filters is selected. Default filters indicated all values on the layer are visible and not user-selected filters are applied. The icon also is set to transparent when the layer visibility is toggled off.
Since:
  • 2.34.0
Source:

toggleSelected()

Sets the Layer model's 'selected' status attribute to true if it's false, and to false if it's true. Executed when a user clicks on this Layer Item in a Layer List view.
Source:

toggleVisibility(event)

Sets the Layer model's visibility status attribute to true if it's false, and to false if it's true. Executed when a user clicks on this view.
Parameters:
Name Type Description
event object The click event on this view component.
Source: