百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

maplibre-gl-lidar

> 编程语言
开源

一个用于可视化激光雷达点云的 MapLibre 插件

198 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个用于可视化激光雷达点云的 MapLibre 插件

maplibre-gl-lidar

A MapLibre GL JS plugin for visualizing LiDAR point clouds using deck.gl.

Features

  • Load and visualize LAS/LAZ/COPC point cloud files (LAS 1.0 - 1.4)
  • Dynamic COPC streaming - viewport-based loading for large cloud-optimized point clouds
  • EPT (Entwine Point Tile) support - stream large point cloud datasets from EPT servers
  • Multiple color schemes: elevation, intensity, classification, RGB
  • Classification legend with toggle - interactive legend to show/hide individual classification types
  • Percentile-based coloring - use 2-98% percentile range for better color distribution (clips outliers)
  • Interactive GUI control panel with scrollable content
  • Point picking - hover over points to see all available attributes (coordinates, elevation, intensity, classification, RGB, GPS time, return number, etc.)
  • Z offset adjustment - shift point clouds vertically for alignment
  • Elevation filtering - filter points by elevation range
  • Automatic coordinate transformation (projected CRS to WGS84)
  • Programmatic API for loading and styling
  • React integration with hooks
  • Vue integration with @geoql/v-maplibre
  • deck.gl PointCloudLayer with optimized chunking for large datasets
  • TypeScript support

Demo

Try the live demo.

Online Viewer

Use the Online Viewer to load and visualize any COPC point cloud by entering a URL. You can also use URL parameters for direct linking:

https://opengeos.org/maplibre-gl-lidar/viewer/?url=https://s3.amazonaws.com/hobu-lidar/autzen-classified.copc.laz

This allows you to share links that automatically load specific point clouds.

Installation

bash
npm install maplibre-gl-lidar

Quick Start

Basic Usage (Vanilla JS/TypeScript)

…

React Usage

…

Vue Usage

The @geoql/v-maplibre package provides a VControlLidar component that wraps maplibre-gl-lidar for Vue/Nuxt applications.

bash
npm install @geoql/v-maplibre maplibre-gl-lidar
xml

  
     console.log('Loaded:', info)"
    />
  

Props

Prop Type Default Description
options LidarControlOptions See defaults Configuration options for the LiDAR control
position 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' 'top-right' Position of the control on the map
defaultUrl string — URL of a point cloud file to auto-load on mount

Events

All LidarControl events are available as Vue events: @load, @loadstart, @loaderror, @unload, @statechange, @stylechange, @collapse, @expand, @streamingstart, @streamingstop, @streamingprogress, @budgetreached.

Exposed Methods

Access methods via template ref:

xml

  

Available methods: loadPointCloud, unloadPointCloud, flyToPointCloud, setPointSize, setColorScheme, setOpacity, setPickable, setUsePercentile, setElevationRange, clearElevationRange, setZOffset, setZOffsetEnabled, getShareUrl, restoreFromUrl, toggle, expand, collapse, getState, getPointClouds, stopStreaming, isStreaming.

Vue examples: EPT Streaming · Classification Filter Full docs: @geoql/v-maplibre LidarControl

API Reference

LidarControl

The main control class implementing MapLibre's IControl interface.

Constructor Options

…

Methods

…

Share URLs use readable query parameters such as url, lon, lat, zoom, pitch, bearing, color, cmap, size, opacity, and zoff.

Theming

The control adapts to light and dark themes. By default (theme: 'auto') it follows the operating system / browser prefers-color-scheme setting. Set theme: 'dark' or theme: 'light' to force a theme, which is handy when pairing the control with a dark basemap, and call setTheme(...) to switch at runtime:

typescript
const control = new LidarControl({ theme: 'dark' });
// later
control.setTheme('auto');

All colors are driven by --lidar-* CSS custom properties, so you can override individual tokens (or the whole palette) in your own stylesheet. Forced themes add a lidar-theme-dark / lidar-theme-light class to the `` element so panels and modals rendered at the document root inherit the theme too.

Resizable panel

The panel can be resized by dragging the grip in its free bottom corner (bottom-left for right-anchored positions, bottom-right for left-anchored positions). It expands to use the available vertical space and shows a vertical scrollbar only when the content overflows.

Events

  • load - Point cloud loaded successfully
  • loadstart - Loading started
  • loaderror - Loading failed
  • unload - Point cloud unloaded
  • statechange - Control state changed
  • stylechange - Styling changed
  • collapse - Panel collapsed
  • expand - Panel expanded
  • streamingstart - Dynamic streaming started
  • streamingstop - Dynamic streaming stopped
  • streamingprogress - Streaming progress update
  • budgetreached - Point budget limit reached

Color Schemes

  • 'elevation' - Viridis-like color ramp based on Z values
  • 'intensity' - Grayscale based on intensity attribute
  • 'classification' - ASPRS standard classification colors
  • 'rgb' - Use embedded RGB colors (if available)

Percentile-Based Coloring

By default, elevation and intensity coloring uses the 2nd-98th percentile range instead of the full min-max range. This clips outliers and provides better color distribution across the point cloud.

typescript
// Percentile coloring is enabled by default
const control = new LidarControl({
  colorScheme: "elevation",
  usePercentile: true, // default
});

// Disable to use full value range (min-max)
control.setUsePercentile(false);

// Check current setting
console.log(control.getUsePercentile()); // true or false

The percentile toggle is also available in the GUI panel when using "Elevation" or "Intensity" color schemes. Uncheck "Use percentile range (2-98%)" to use the full value range.

Point Picking

When pickable is enabled, hovering over points displays a tooltip with all available attributes:

  • X, Y, Z - Coordinates and elevation
  • Intensity - Reflectance value
  • Classification - ASPRS class name (Ground, Building, Vegetation, etc.)
  • Red, Green, Blue - RGB color values (if available)
  • GpsTime - GPS timestamp
  • ReturnNumber / NumberOfReturns - Return information
  • PointSourceId - Scanner source ID
  • ScanAngle - Scan angle
  • And more (EdgeOfFlightLine, ScanDirectionFlag, UserData, etc.)

Enable via constructor option or toggle in the GUI panel:

typescript
// Via constructor
const control = new LidarControl({ pickable: true });

// Or programmatically
control.setPickable(true);

// Optionally filter which fields to display
control.setPickInfoFields([
  "Classification",
  "Intensity",
  "GpsTime",
  "ReturnNumber",
]);

Z Offset

Shift point clouds vertically for alignment with terrain or other data:

typescript
// Via constructor
const control = new LidarControl({
  zOffsetEnabled: true,
  zOffset: 50, // Shift up 50 meters
});

// Or programmatically
control.setZOffsetEnabled(true);
control.setZOffset(50);

// Get current offset
console.log(control.getZOffset()); // 50

The Z offset can also be adjusted interactively via the "Z Offset" checkbox and slider in the GUI panel.

Classification Legend

When using the "Classification" color scheme, an interactive legend appears showing all classification types found in the point cloud data. Each classification displays:

  • A color swatch matching the ASPRS standard colors
  • The classification name (Ground, Building, Vegetation, etc.)
  • A checkbox to toggle visibility

Features:

  • Show All / Hide All buttons - Quickly toggle all classifications at once
  • Individual toggles - Show or hide specific classification types
  • Auto-detection - Classifications are automatically detected from loaded data
  • Streaming support - Classifications update as data streams in for COPC files
…

ASPRS Classification Codes:

Code Name
2 Ground
3 Low Vegetation
4 Medium Vegetation
5 High Vegetation
6 Building
7 Low Point (Noise)
9 Water
17 Bridge Deck

Dynamic COPC Streaming

For large COPC (Cloud Optimized Point Cloud) files, dynamic streaming loads only the points visible in the current viewport, dramatically reducing initial load time and memory usage.

Key features:

  • Viewport-based loading - Only loads octree nodes visible in the current map view
  • Level-of-detail (LOD) - Automatically selects appropriate detail level based on zoom
  • Center-first priority - Points near the viewport center load first
  • Point budget - Limits total points in memory (default: 5 million)

How it works:

  1. When loading a COPC file (from URL or local file), dynamic mode is used by default
  2. As you pan/zoom the map, new nodes are streamed based on viewport
  3. Deeper octree levels (more detail) load as you zoom in
  4. Parent nodes provide coverage where child nodes don't exist
typescript
// Dynamic loading is the default for COPC files
const control = new LidarControl();
control.loadPointCloud("https://example.com/large-pointcloud.copc.laz");

// Explicitly set loading mode
const control = new LidarControl({
  copcLoadingMode: "dynamic", // or 'full' for complete load
  streamingPointBudget: 10_000_000, // 10 million points max
});

// Override per-load
control.loadPointCloud(file, { loadingMode: "full" }); // Force full load
control.loadPointCloud(url, { loadingMode: "dynamic" }); // Force streaming

Loading modes:

  • 'dynamic' (default for COPC) - Stream nodes based on viewport, ideal for large files
  • 'full' - Load entire point cloud upfront, better for small files

Note: Non-COPC files (regular LAS/LAZ) always use full loading mode since they don't have the octree structure required for streaming.

EPT (Entwine Point Tile) Support

maplibre-gl-lidar supports Entwine Point Tile (EPT) datasets, a widely-used format for serving large point clouds over HTTP with viewport-based streaming.

Key features:

  • Directory-based format - Metadata in ept.json, hierarchy in ept-hierarchy/, data in ept-data/
  • Viewport-based streaming - Points load dynamically based on current map view
  • LAZ compression - Efficient data transfer using LAZ compression
  • Automatic CRS transformation - Coordinates transformed from source CRS to WGS84

Loading EPT data:

typescript
// Load EPT dataset by URL (automatically detected via ept.json)
lidarControl.loadPointCloud("https://na-c.entwine.io/dublin/ept.json");

// Or load programmatically
lidarControl.loadPointCloudEptStreaming(
  "https://na-c.entwine.io/dublin/ept.json",
  {
    pointBudget: 5_000_000, // Max points in memory
  }
);

Sample EPT datasets:

  • Dublin, Ireland: https://na-c.entwine.io/dublin/ept.json
  • New York City (4.7B points): https://na-c.entwine.io/nyc/ept.json
  • Red Rocks: https://na-c.entwine.io/red-rocks/ept.json

Note: EPT datasets require CORS support from the server. The sample datasets from entwine.io are CORS-enabled.

React Hooks

useLidarState

typescript
const {
  state,
  setState,
  setPointSize,
  setOpacity,
  setColorScheme,
  setUsePercentile,
  setElevationRange,
  setZOffsetEnabled,
  setZOffset,
  toggle,
  reset,
} = useLidarState(initialState?);

usePointCloud

typescript
c

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptdeck-glgeospatiallidarmaplibre

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言