Skip to content
Docs version
@hungpvq/vue-map@1.1.0@hungpvq/vue-map-core@1.1.0@hungpvq/vue-map-dataset@1.1.0@hungpvq/vue-map-draw@1.1.0@hungpvq/map-draw@1.1.0@hungpvq/react-map@1.1.0@hungpvq/react-map-core@1.1.0@hungpvq/react-map-dataset@1.1.0@hungpvq/react-map-draw@1.1.0

List UI

How a dataset appears in LayerControl. Prefer the builder.

ts
import { createMultiLegend } from '@hungpvq/map-dataset/menu';
import { createDatasetPartListViewUiComponent, createDatasetPartListViewUiComponentBuilder } from '@hungpvq/map-dataset';
import { createMenuBuilder, createMenuItemToggleShow } from '@hungpvq/map-dataset/menu';
import { mdiDownload } from '@mdi/js';

// Shortcut (defaults: opacity menu, move up/down, add to group)
const simple = createDatasetPartListViewUiComponent('My Layer');
simple.color = '#ff6b6b';
simple.opacity = 0.8;

const list = createDatasetPartListViewUiComponentBuilder('My Layer')
  .setColor('#4ecdc4')
  .setOpacity(0.9)
  .setIndex(1)
  .setGroup({ id: 'g1', name: 'Group 1' })
  .setLegend(
    createMultiLegend([
      { type: 'color', value: { text: 'Fill', value: '#4ecdc4' } },
    ]),
  )
  .configInitShowLegend()
  .addMenu(createMenuItemToggleShow())
  .addMenus([
    createMenuBuilder()
      .item()
      .setLocation('menu')
      .setName('Download')
      .setIcon(mdiDownload)
      .setHidden(({ context }) => context?.role !== 'admin')
      .setClick(({ layer }) => download(layer))
      .build(),
  ])
  .build();

Builder methods

MethodExampleEffect
setColor.setColor('#4ecdc4')Swatch / default paint
setOpacity.setOpacity(0.8)Initial opacity
setIndex.setIndex(2)Sort in the list
setGroup.setGroup('g1') or { id, name }Initial group
setLegend.setLegend(createMultiLegend([...]))Legend block
configDisabledOpacity()No opacity control / no auto opacity menu
configDisabledDelete()Hide row delete
configDisabledMove()Do not add Move up/down
configDisabledAddToGroup()Do not add Add to group
configInitShowLegend()Legend expanded
addMenu / addMenussee MenusExtra actions

Each configDisabled*(true) is the default when called with no arg. Pass false to turn the flag off.

List items (type: 'list') automatically get Move up, Move down, and Add to group unless those flags are set. Sub-items (list-item) do not.

Export and Attribute table are not auto-added by the list builder. Add them yourself, or use createGeoJsonDataset which attaches both. See Export and Attribute table.

Types for custom list / drag UIs

When building a custom layer list (or mirroring LayerControl drag/group), import types from @hungpvq/map-dataset:

ts
import type {
  IListViewUI,
  LayerListItem,
  LayerListTreeNode,
  LayerListGroupTree,
  ListViewGroupRef,
} from '@hungpvq/map-dataset';
import {
  convertListToTree,
  convertTreeToList,
  mergeEmptyGroups,
  isGroupNode,
} from '@hungpvq/map-dataset';

const rows: LayerListItem[] = /* … */;
const tree: LayerListTreeNode[] = convertListToTree(rows);
TypeUse
IListViewUIDataset list-part protocol (group may be string | { id, name, children? })
LayerListItemFlat drag-list row: IListViewUI ∩ tree Item with group?: ListViewGroupRef
LayerListTreeNode / LayerListGroupTreeTree nodes after convertListToTree

IListViewUI.group can be a bare string; convertListToTree expects object groups with .id. Prefer setGroup({ id, name }) or normalize before converting.

Sub-list and group list

ts
import {
  createDatasetPartGroupSubListViewUiComponentBuilder,
  createDatasetPartSubListViewUiComponentBuilder,
} from '@hungpvq/map-dataset';

const group = createDatasetPartGroupSubListViewUiComponentBuilder('Group')
  .setColor('#00bfff')
  .configInitShowChildren()
  .build();

const child = createDatasetPartSubListViewUiComponentBuilder('Child')
  .setColor('#ffa500')
  .build();

group.add(child);

createDatasetPartGroupSubListViewUiComponent / createDatasetPartSubListViewUiComponent are the no-builder shortcuts.

Events

The list node (not LayerControl) emits:

EventPayload
toggleShow{ show: boolean, dataset }
changeOpacity{ opacity: number, dataset }
ts
list.on('toggleShow', ({ show }) => console.log(show));
list.on('changeOpacity', ({ opacity }) => console.log(opacity));

See Events. Legend helpers: createLegend / createMultiLegend.