# 工具函数

## 全局 API · transformCoord

### transformCoord(data, from, to, projectionCode?)

* **类型**：`Function`
* **归属**：自定义
* **参数**：
  * `{number[]} data` — `[x, y]`
  * `{string} from` — `'wgs84'` | `'gcj02'` | `'webmercator'` | `'map'` …
  * `{string} to` — 同上
  * `{string|Object} [projectionCode]` — 自定义投影
* **返回值**：`number[]`
* **说明**：内部 `new Transform(...)`。`from/to` 为 `'map'` 时依赖当前 `context` 中的 Map。
* **用法**：

```js
import { transformCoord } from '@its-cool/simple-map';

const gcj = transformCoord([120.15, 30.28], 'wgs84', 'gcj02');
const merc = transformCoord(gcj, 'gcj02', 'webmercator');
```

示例页：[`/transform`](/transform)

---

## 全局 API · mapTools

### mapTools.pipeInspection(options)

* **类型**：`Function`
* **参数**：
  * `{Object} options`
    * `{number} options.wkid` — `3857` 时会把坐标 `toWgs84`
    * `{Array<{x,y}>} options.list` — 轨迹折线
    * `{string} options.layerIds` — WFS typeName
    * `{Function} options.callback(featuresProps[])` — 结果回调
    * `{Object} [options.cql]` — 额外 CQL 条件键值
* **返回值**：无（异步 `fetch`）
* **用法**：

```js
import { mapTools } from '@its-cool/simple-map';

mapTools.pipeInspection({
  wkid: 3857,
  list: [{ x: 13528400, y: 3676400 }, { x: 13528500, y: 3676500 }],
  layerIds: 'water:pipe',
  callback(rows) {
    console.log(rows);
  }
});
```

---
