---
title: "useScriptMapLibre"
description: "当你需要直接访问 MapLibre 命名空间或正在构建自己的地图组件时，请使用 useScriptMapLibre()。"
canonical_url: "https://nuxt-scripts.zhcndoc.com/scripts/maplibre/api/use-script-maplibre"
last_updated: "2026-09-23T10:33:14.742Z"
---

当你需要直接访问 MapLibre 命名空间或正在构建自己的地图组件时，请使用 `useScriptMapLibre()`{lang="ts"}。

::script-types{script-key="maplibre" filter="useScriptMapLibre"}
::

```ts
const { onLoaded } = useScriptMapLibre()

onLoaded(({ maplibregl }) => {
  const bounds = new maplibregl.LngLatBounds(points)
  // 直接使用 MapLibre API。
})
```

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
