# @conveyal/lonlat 中文文档

规范地址：https://npmcn.com/package/%40conveyal/lonlat/

版本：1\.4\.1
npm 元数据更新时间：2022-06-12T16:38:58.189Z
中文译文更新时间：2026-11-10T18:17:31.406Z
软件包许可：MIT

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

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

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

- 包体积（解压后）：150 kB，15 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2016-10-29T09:14:17.043Z
- 最新版本发布：2021-07-28T06:50:51.606Z
- 近 30 天下载量：4063（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：8（近 12 个月 0 个）

## 中文简介

连线/纵向正常化

## 安装

```sh
npm install @conveyal/lonlat
```

也可以使用：`pnpm add @conveyal/lonlat`、`yarn add @conveyal/lonlat`、`bun add @conveyal/lonlat`

## README

# 龙拉

[![NPM version](https://img.shields.io/npm/v/@conveyal/lonlat.svg?maxAge=2592000&style=flat-square)](https://www.npmjs.com/package/@conveyal/lonlat) [![Build status](https://img.shields.io/travis/conveyal/lonlat.svg?style=flat-square)](https://travis-ci.org/conveyal/lonlat)

隆/拉特正常化事业...**叹息**。 。 。 .

没有人同意代表Lon/lat的标准方式。 这是一个小型的正常化图书馆。 使用此功能在内部处理前将所有外部输入转换为外出格式,并在输出时转换为外出格式右出.

## API 密码

#### 目录

-   [lonlat.类型.输入](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinput)
-   [lonlat.types. 输出](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesoutput)
    -   [属性](https://npmcn.com/package/%40conveyal/lonlat/#readme-properties)
-   [lonlat. 类型. 点](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypespoint)
    -   [属性](https://npmcn.com/package/%40conveyal/lonlat/#readme-properties-1)
-   [lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)
-   [传道/隆拉特](https://npmcn.com/package/%40conveyal/lonlat/#readme-conveyallonlat)
    -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters)
    -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples)
    -   [从坐标](https://npmcn.com/package/%40conveyal/lonlat/#readme-fromcoordinates)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-1)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-1)
    -   [从拉特伦](https://npmcn.com/package/%40conveyal/lonlat/#readme-fromlatlng)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-2)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-2)
    -   [从点](https://npmcn.com/package/%40conveyal/lonlat/#readme-frompoint)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-3)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-3)
    -   [从 String 从](https://npmcn.com/package/%40conveyal/lonlat/#readme-fromstring)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-4)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-4)
    -   [从LatFirstString 读取](https://npmcn.com/package/%40conveyal/lonlat/#readme-fromlatfirststring)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-5)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-5)
    -   [等价键](https://npmcn.com/package/%40conveyal/lonlat/#readme-isequal)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-6)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-6)
    -   [打印](https://npmcn.com/package/%40conveyal/lonlat/#readme-print)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-7)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-7)
    -   [坐标](https://npmcn.com/package/%40conveyal/lonlat/#readme-tocoordinates)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-8)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-8)
    -   [文件夹](https://npmcn.com/package/%40conveyal/lonlat/#readme-toleaflet)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-9)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-9)
    -   [点](https://npmcn.com/package/%40conveyal/lonlat/#readme-topoint)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-10)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-10)
    -   [倒数](https://npmcn.com/package/%40conveyal/lonlat/#readme-tostring)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-11)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-11)
    -   [拖动第一串](https://npmcn.com/package/%40conveyal/lonlat/#readme-tolatfirststring)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-12)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-12)
    -   [到像素](https://npmcn.com/package/%40conveyal/lonlat/#readme-topixel)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-13)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-13)
    -   [从像素](https://npmcn.com/package/%40conveyal/lonlat/#readme-frompixel)
        -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-14)
        -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-14)
-   [PIXELS PER TIE 常规](https://npmcn.com/package/%40conveyal/lonlat/#readme-pixels_per_tile)
-   [PIXELS PER TIE 常规](https://npmcn.com/package/%40conveyal/lonlat/#readme-pixels_per_tile-1)
-   [经度到像素](https://npmcn.com/package/%40conveyal/lonlat/#readme-longitudetopixel)
    -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-15)
    -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-15)
-   [纬度到像素](https://npmcn.com/package/%40conveyal/lonlat/#readme-latitudetopixel)
    -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-16)
    -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-16)
-   [马利亚特](https://npmcn.com/package/%40conveyal/lonlat/#readme-max_lat)
-   [像素到纬度](https://npmcn.com/package/%40conveyal/lonlat/#readme-pixeltolongitude)
    -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-17)
    -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-17)
-   [像素到纬度](https://npmcn.com/package/%40conveyal/lonlat/#readme-pixeltolatitude)
    -   [参数](https://npmcn.com/package/%40conveyal/lonlat/#readme-parameters-18)
    -   [实例](https://npmcn.com/package/%40conveyal/lonlat/#readme-examples-18)

### lonlat.类型.输入

(类型)

未知输入类型 。 必须是以下之一:

-   数组:含有2个元素的数组。 第一种是经纬度,第二种是纬度.
-   字符串:格式中的字符串 `longitude,latitude`
-   对象 (x, y 坐标): 对象为 `x` 财务报告和审定财务报表 `y` 属性. `x` 表示经度 `y` 代表纬度.
-   对象( lat, Lon ): 有经纬度特性的天体. 属性可以被命名为各种事物. 对于经度,下列任何一种都是有效的: `lon`, (中文(简体) ), `lng` 或者说 `longitude` 对于纬度,下列任何一种都是有效的: `lat` 或者说 `latitude`

类型 : ([阵列](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array) | [字符串](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [对象](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)(中文(简体) )

### lonlat.types. 输出

(类型)

已标准化的 Lon/ lat 对象 .

类型 : [对象](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)

#### 属性

-   `lat` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
-   `lon` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**

### lonlat. 类型. 点

(类型)

有 x/y 数字值的对象.

类型 : [对象](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)

#### 属性

-   `x` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
-   `y` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**

### lonlat.types. 无效坐标例外

(例外类型)

在提供无效坐标时出错 .

类型 : [错误](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)

### 传道/隆拉特

解析未知输入类型 .

#### 参数

-   `unknown` **[lonlat.类型.输入](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinput)**

#### 实例

```javascript
var lonlat = require('@conveyal/lonlat')

// Object with lon/lat-ish attributes
var position = lonlat({ lon: 12, lat: 34 })         // { lon: 12, lat: 34 }
position = lonlat({ lng: 12, lat: 34 })             // { lon: 12, lat: 34 }
position = lonlat({ longitude: 12, latitude: 34 })  // { lon: 12, lat: 34 }
position = lonlat({ lng: 12, latitude: 34 })        // { lon: 12, lat: 34 }

// coordinate array
position = lonlat([12, 34])   // { lon: 12, lat: 34 }

// string
position = lonlat('12,34')   // { lon: 12, lat: 34 }

// object with x and y attributes
position = lonlat({ x: 12, y: 34 })   // { lon: 12, lat: 34 }

// the following will throw errors
position = lonlat({ lon: 999, lat: 34 })   // Error: Invalid longitude value: 999
position = lonlat({ lon: 12, lat: 999 })   // Error: Invalid latitude value: 999
position = lonlat({})                      // Error: Invalid latitude value: undefined
position = lonlat(null)                    // Error: Value must not be null or undefined
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**

回返 **[lonlat.types. 输出](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesoutput)**

#### 从坐标

**化名 :** 从吉奥杰森  

尝试从一组坐标剖析 .

##### 参数

-   `coordinates` **[阵列](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** 格式中的数组: \[经度, 纬度\]

##### 实例

```javascript
var lonlat = require('@conveyal/lonlat')

var position = lonlat.fromCoordinates([12, 34])   // { lon: 12, lat: 34 }
position = lonlat.fromGeoJSON([12, 34])           // { lon: 12, lat: 34 }
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**

回返 **[lonlat.types. 输出](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesoutput)**

#### 从拉特伦

**化名 :** 从叶片  

尝试从对象中解析 .

##### 参数

-   `lonlat` **[对象](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 带有 `lon`, (中文(简体) ), `lng` 或者说 `longitude` 属性和 a `lat` 或者说 `latitude` 属性

##### 实例

```javascript
var lonlat = require('@conveyal/lonlat')

var position = lonlat.fromLatlng({ longitude: 12, latitude: 34 })   // { lon: 12, lat: 34 }
position = lonlat.fromLeaflet({ lng: 12, lat: 34 })                 // { lon: 12, lat: 34 }
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**

回返 **[lonlat.types. 输出](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesoutput)**

#### 从点

尝试从对象中解析 .

##### 参数

-   `point` **[对象](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 带有 `x` 属性表示 `longitude` (单位:千美元) `y` 属性表示 `latitude`

##### 实例

```javascript
var lonlat = require('@conveyal/lonlat')

var position = lonlat.fromPoint({ x: 12, y: 34 })   // { lon: 12, lat: 34 }
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**

回返 **[lonlat.types. 输出](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesoutput)**

#### 从 String 从

**化名 :** 从Lon FirstString 读取  

尝试从经度出现在纬度之前的字符串中解析 .

##### 参数

-   `str` **[字符串](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 格式中的字符串 : `longitude,latitude`

##### 实例

```javascript
var lonlat = require('@conveyal/lonlat')

var position = lonlat.fromString('12,34')          // { lon: 12, lat: 34 }
var position = lonlat.fromLonFirstString('12,34')  // { lon: 12, lat: 34 }
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**

回返 **[lonlat.types. 输出](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesoutput)**

#### 从LatFirstString 读取

尝试从经度前显示纬度的字符串中解析 .

##### 参数

-   `str` **[字符串](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 格式中的字符串 : `latitude,longitude`

##### 实例

```javascript
var lonlat = require('@conveyal/lonlat')

var position = lonlat.fromLatFirstString('12,34') // { lon: 34, lat: 12 }
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**

回返 **[lonlat.types. 输出](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesoutput)**

#### 等价键

确定两个输入是否相等

##### 参数

-   `lonlat1` **[lonlat.类型.输入](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinput)**
-   `lonlat2` **[lonlat.类型.输入](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinput)**
-   `epsilon` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 最大可接受偏差视为等同. (可选,默认) `0`(中文(简体) )

##### 实例

```javascript
var lonlat = require('@conveyal/lonlat')

var isEqual = lonlat.isEqual('12,34', [12, 34])   // true
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**

回返 **[布尔](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

#### 打印

##### 参数

-   `input` **[lonlat.类型.输入](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinput)**
-   `fixed` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 十进制位数 (可选,默认) `5`(中文(简体) )

##### 实例

```javascript
var lonlat = require('@conveyal/lonlat')

var pretty = lonlat.print('12.345678,34')   // '12.34568, 34.00000'
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**

回返 **[字符串](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 带有格式的字符串 `longitude,latitude` 四舍五入为 指定的小数位数 `fixed`

#### 坐标

**化名 :** 切换到吉奥杰森  

翻译为坐标阵列.

##### 参数

-   `input` **[lonlat.类型.输入](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinput)**

##### 实例

```javascript
var lonlat = require('@conveyal/lonlat')

var coords = lonlat.toCoordinates('12,34')   // [12, 34]
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**

回返 **[阵列](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** 格式 \[经度,纬度\] 的数组

#### 文件夹

翻译为: [叶子LatLng](http://leafletjs.com/reference-1.0.3.html#latlng) 对象. 该功能需要安装为全局变量 `L` 在窗口环境中.

##### 参数

-   `input` **[lonlat.类型.输入](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinput)**

##### 实例

```javascript
var lonlat = require('@conveyal/lonlat')

var position = lonlat.toLeaflet({ lat: 12, long: 34 })   // Leaflet LatLng object
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**

回返 **[对象](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 叶片 LatLng 对象

#### 点

翻译为指向对象.

##### 参数

-   `input` **[lonlat.类型.输入](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinput)**

##### 实例

```javascript
var lonlat = require('@conveyal/lonlat')

var point = lonlat.toPoint('12,34')   // { x: 12, y: 34 }
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**

回返 **[对象](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 对象为 `x` 财务报告和审定财务报表 `y` 分别代表纬度和经度的属性

#### 倒数

**化名 :** 转到 Lon First String  

在纬度之前显示经度的地方翻译以协调字符串.

##### 参数

-   `input` **[lonlat.类型.输入](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinput)**

##### 实例

```javascript
var lonlat = require('@conveyal/lonlat')

var str = lonlat.toString({ lat: 12, longitude: 34 })          // '34,12'
var str = lonlat.toLonFirstString({ lat: 12, longitude: 34 })  // '34,12'
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**

回返 **[字符串](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 格式“ 纬度” 中的字符串

#### 拖动第一串

在经纬度之前显示纬度的地方翻译以协调字符串.

##### 参数

-   `input` **[lonlat.类型.输入](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinput)**

##### 实例

```javascript
var lonlat = require('@conveyal/lonlat')

var str = lonlat.toLatFirstString({ lat: 12, longitude: 34 })  // '12,34'
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**

回返 **[字符串](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 格式“ 纬度” 中的字符串

#### 到像素

将坐标转换为像素 .

##### 参数

-   `input` **[lonlat.类型.输入](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinput)**
-   `zoom` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**

##### 实例

```javascript
var pixel = lonlat.toPixel({lon: -70, lat: 40}, 9) //= {x: 40049.77777777778, y:49621.12736343896}
```

-   掷出 **[lonlat.types. 无效坐标例外](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesinvalidcoordinateexception)**
-   掷出 **[错误](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** 如果纬度高于或低于 `MAX_LAT`
-   掷出 **[错误](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** 若为 `zoom` 未定义.

回返 **[对象](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 对象为 `x` 财务报告和审定财务报表 `y` 代表像素坐标的属性

#### 从像素

从相相出.

##### 参数

-   `pixel` **[lonlat. 类型. 点](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypespoint)**
-   `zoom` **[数目](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**

##### 实例

```javascript
var ll = lonlat.fromPixel({x: 40000, y: 50000}, 9) //= {lon: -70.13671875, lat: 39.1982053488948}
```

回返 **[lonlat.types. 输出](https://npmcn.com/package/%40conveyal/lonlat/#readme-lonlattypesoutput)**

### PIXELS PER TIE 常规

像素转换和常数取自 [https://wiki.openstreetmap.org/wiki/Slippy map tilenames# 执行](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Implementations)

### PIXELS PER TIE 常规

每块像素.

### 经度到像素

将经度转换为给定的像素值 `zoom` 级别.

#### 参数

-   `longitude` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
-   `zoom` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**

#### 实例

```javascript
var xPixel = lonlat.longitudeToPixel(-70, 9) //= 40049.77777777778
```

回返 **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 像素

### 纬度到像素

将纬度转换为给定的像素值 `zoom` 级别.

#### 参数

-   `latitude` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
-   `zoom` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**

#### 实例

```javascript
var yPixel = lonlat.latitudeToPixel(40, 9) //= 49621.12736343896
```

回返 **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 像素

### 马利亚特

有效Mercator投影转换的最大纬度.

### 像素到纬度

将像素转换为经度值,并给出一个缩放级别.

#### 参数

-   `x` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
-   `zoom` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**

#### 实例

```javascript
var lon = lonlat.pixelToLongitude(40000, 9) //= -70.13671875
```

回返 **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 经度

### 像素到纬度

将像素转换为显示缩放级的纬度值.

#### 参数

-   `y` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
-   `zoom` **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**

#### 实例

```javascript
var lat = lonlat.pixelToLatitude(50000, 9) //= 39.1982053488948
```

回返 **[编号](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 纬度

## 常见问题

### @conveyal/lonlat 是什么？

连线/纵向正常化

### 如何安装 @conveyal/lonlat？

在项目目录运行 npm install @conveyal/lonlat，或使用 pnpm add / yarn add / bun add。

### @conveyal/lonlat 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @conveyal/lonlat 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @conveyal/lonlat 可以商用吗？

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

### @conveyal/lonlat 的下载量有多少？

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

### @conveyal/lonlat 还在维护吗？

最新版本 1\.4\.1 发布于 2021/07/28（5 年前）；至今共发布 8 个版本，其中过去 12 个月发布了 0 个；首次发布于 2016/10/29。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

