# @fleetbase/leaflet-routing-machine 中文文档

规范地址：https://npmcn.com/package/%40fleetbase/leaflet-routing-machine/

版本：3\.2\.17
npm 元数据更新时间：2026-07-02T03:37:05.744Z
中文译文更新时间：2026-11-14T22:31:29.536Z
软件包许可：ISC

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40fleetbase/leaflet-routing-machine
原文对照：https://npmcn.com/package/%40fleetbase/leaflet-routing-machine/?lang=original
项目主页：https://github.com/fleetbase/leaflet-routing-machine
源码仓库：https://github.com/fleetbase/leaflet-routing-machine

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：19 MB，487 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：3 个
- 首次发布：2022-06-23T06:00:07.756Z
- 最新版本发布：2025-05-30T06:02:16.673Z
- 近 30 天下载量：3561（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：6（近 12 个月 0 个）

## 中文简介

用于传单的无害环境管理模块

## 安装

```sh
npm install @fleetbase/leaflet-routing-machine
```

也可以使用：`pnpm add @fleetbase/leaflet-routing-machine`、`yarn add @fleetbase/leaflet-routing-machine`、`bun add @fleetbase/leaflet-routing-machine`

## README

# [叶片跑道机](https://npmcn.com/package/%40fleetbase/leaflet-routing-machine/\(https://www.liedman.net/leaflet-routing-machine/\)) [![NPM version](https://img.shields.io/npm/v/leaflet-routing-machine.svg)](https://www.npmjs.com/package/leaflet-routing-machine) ![Leaflet 1.0 compatible!](https://img.shields.io/badge/Leaflet%201.0-%E2%9C%93-1EB300.svg?style=flat) [![Join the chat at https://gitter.im/leaflet-routing-machine/Lobby](https://badges.gitter.im/leaflet-routing-machine/Lobby.svg)](https://gitter.im/leaflet-routing-machine/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

**此插件几乎无法维护 !** 自从我有理由与路由或叶片合作以来,这已经很长一段时间了,看起来不会改变。 我不花时间来维护这个插件, 如果你想接任维护者 随时联系我 [个人信息](mailto:per@liedman.net)。 。 。 .

在叶片地图上找到从A到B的路. 插件支持多个后端 :

-   [OSRM 操作程序](http://project-osrm.org/) - 内置和默认使用(第5版)
-   [映射框方向 API](https://www.mapbox.com/developers/api/directions/) - 与班级搭建 `L.Routing.Mapbox`
-   [图表Hopper](https://graphhopper.com/) - 通过插件 [缩写](https://github.com/perliedman/lrm-graphhopper)
-   [马普森·瓦尔哈拉](https://mapzen.com/projects/valhalla/) - 通过插件 [瓦尔哈拉](https://github.com/valhalla/lrm-valhalla)
-   [TomTom 在线运行 API](http://developer.tomtom.com/io-docs) - 通过插件 [轻而易举](https://github.com/mrohnstock/lrm-tomtom) 以 [马蒂亚斯·罗恩斯托克](https://github.com/mrohnstock)
-   通过插件支持OSRM版本 4 的后遗症 [错误4](https://github.com/perliedman/lrm-osrm4)
-   Esri - 通过插件 [爱丽丝](https://github.com/jgravois/lrm-esri)

## 特征

-   标准的叶片控制,叶片的外观和感觉
-   从起点到目的地,有可能通过点数
-   通过地址输入和使用地图添加、编辑并去除出出处
-   多种语言支持
-   高度定制用于高级用途
-   自定义外观( 它们/ 皮肤)
-   根据ISC许可证发布的开源(与麻省理工学院许可证大致相当)

**转到 [叶花跑道机器站点](https://www.liedman.net/leaflet-routing-machine/) 需要更多信息、演示、辅导等.**

**2020-04-06增订:** 出道后,Leaflet跑道机依赖于OSRM的演示服务器. 此时,演示服务器(在插件范围之外,且插件作者不受控制)是 [不再维护, 且其 SSL 证书已过期](https://github.com/Project-OSRM/osrm-backend/issues/5655)。该插件将无法工作,除非您 [配置路由后端](https://www.liedman.net/leaflet-routing-machine/tutorials/alternative-routers/) 你自己来 我很遗憾地说,据我所知,不存在好的违约.

## 支助和新特点

Leaflet Routing Machine在许多方面已经是一个完整的路由UI特性. 最有可能的是,你的要求已经得到满足了,不需要多少适应.

关于问题和讨论,你不妨看看 [叶片跑步机闪光器](https://gitter.im/leaflet-routing-machine/Lobby)。 。 。 .

## 大楼

```sh
yarn bundle
```

这需要 [节点和npm](http://nodejs.org/),或 `yarn`。 。 。 .

# 使用量

下载 [最新发布](https://github.com/fleetbase/leaflet-routing-machine/releases),或通过 [unpkg.com (英语)](https://unpkg.com/)。 。 。 .

```html
<link rel="stylesheet" href="https://unpkg.com/leaflet-routing-machine@3.2.12/dist/leaflet-routing-machine.css" />
<script src="https://unpkg.com/leaflet-routing-machine@3.2.12/dist/leaflet-routing-machine.js"></script>
```

或通过npm/yarn:

```sh
npm install --save @fleetbase/leaflet-routing-machine
```

```sh
yarn add @fleetbase/leaflet-routing-machine
```

```javascript
import * as L from 'leaflet';
import { OSRMv1, Control as RoutingControl } from '@fleetbase/leaflet-routing-machine';

const map = new L.Map();
const serviceUrl = 'https://routing.fleetbase.io';
const router = new OSRMv1({ serviceUrl, profile: 'driving' });
const routingControl = new RoutingControl({ waypoints: [...], router }).addTo(leafletMap);

```

## 自定义路口标记

您可以自定义路口标记 `markerOptions` 选项 `RoutingControl`。 。 。 .

```javascript
import * as L from 'leaflet';
import { OSRMv1, Control as RoutingControl } from '@fleetbase/leaflet-routing-machine';

const map = new L.Map();
const serviceUrl = 'https://routing.fleetbase.io';
const router = new OSRMv1({ serviceUrl, profile: 'driving' });
const routingControl = new RoutingControl({ 
    waypoints: [...], 
    markerOptions: {
        icon: L.icon({ ... })
    },
    router 
}).addTo(leafletMap);

```

**转到 [叶花跑道机器站点](http://www.liedman.net/leaflet-routing-machine/) 需要更多信息、演示、辅导等.**

## 常见问题

### @fleetbase/leaflet-routing-machine 是什么？

用于传单的无害环境管理模块

### 如何安装 @fleetbase/leaflet-routing-machine？

在项目目录运行 npm install @fleetbase/leaflet-routing-machine，或使用 pnpm add / yarn add / bun add。

### @fleetbase/leaflet-routing-machine 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/fleetbase\_\_leaflet-routing-machine 是否存在。

### @fleetbase/leaflet-routing-machine 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @fleetbase/leaflet-routing-machine 可以商用吗？

@fleetbase/leaflet-routing-machine 使用 ISC 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @fleetbase/leaflet-routing-machine 的下载量有多少？

根据 npm 官方下载统计，@fleetbase/leaflet-routing-machine 在 2026/10/15 – 2026/11/13 这 30 天内被下载 3,561 次，日均约 119 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @fleetbase/leaflet-routing-machine 还在维护吗？

最新版本 3\.2\.17 发布于 2025/05/30（1\.5 年前）；至今共发布 6 个版本，其中过去 12 个月发布了 0 个；首次发布于 2022/06/23。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

