Files
test-map-distance/plan/v0.0.1.md
2026-01-09 22:54:07 +08:00

34 lines
744 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 地图两点距离计算
## 需求
使用高德地图 API实现输入起点地址和终点地址计算两者之间的直线距离。
## 实现方案
1. 使用高德地图**地理编码 API**将地址转换为经纬度坐标
2. 使用**Haversine 公式**计算两点间的直线距离
## API 依赖
- 高德地理编码 API: `https://restapi.amap.com/v3/geocode/geo`
- 需要在高德开放平台申请 API Key
## 输入输出
- 输入:起点地址(字符串)、终点地址(字符串)
- 输出:距离(米/公里)
## 文件结构
```
src/
index.ts # 主逻辑实现
```
## 参考链接- 高德开放平台:
https://console.amap.com/dev/key/app
创建应用类型,选择 Web 服务,获取 API Key。