---
title: "useScriptLeaflet"
description: "当你需要直接访问 Leaflet 命名空间或构建自己的地图组件时，请使用 useScriptLeaflet()。"
canonical_url: "https://nuxt-scripts.zhcndoc.com/scripts/leaflet/api/use-script-leaflet"
last_updated: "2026-08-11T09:33:15.161Z"
---

当你需要直接访问 Leaflet 命名空间或构建自己的地图组件时，请使用 `useScriptLeaflet()`。

<script-types filter="useScriptLeaflet" script-key="leaflet">



</script-types>

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

onLoaded(({ L }) => {
  const bounds = L.latLngBounds(points)
  // 直接使用 Leaflet API。
})
```
