geo/TIANDITU_SETUP.md

67 lines
1.8 KiB
Markdown
Raw Permalink 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.

# 天地图配置指南
## 1. 申请天地图API Key
要使用天地图服务你需要先申请API Key
1. 访问天地图官网https://www.tianditu.gov.cn/
2. 点击右上角"控制台"进入开发者控制台https://console.tianditu.gov.cn/
3. 注册账号并登录
4. 在控制台中创建应用并获取API Key
## 2. 配置API Key
获取API Key后需要在项目中配置
### 方法1修改配置文件
编辑 `src/config/tianditu.js` 文件,将 `API_KEY` 替换为你的API Key
```javascript
export const TIANDITU_CONFIG = {
API_KEY: '你的API_KEY', // 替换这里
// ... 其他配置
}
```
### 方法2直接修改组件
编辑 `src/components/TiandituMap.vue` 文件,找到 `apiKey` 字段并替换:
```javascript
const tiandituConfig = {
apiKey: '你的API_KEY', // 替换这里
// ... 其他配置
}
```
## 3. 启动项目
配置完成后,启动项目:
```bash
npm run dev
```
## 4. 功能说明
- **矢量地图**:显示道路、建筑等矢量信息
- **影像地图**:显示卫星影像
- **图层切换**:点击右上角按钮可以切换不同图层
- **地图交互**:支持缩放、平移等常用地图操作
## 5. 常见问题
### Q: 地图显示空白或加载失败
A: 请确认API Key是否正确配置并检查网络连接
### Q: 如何修改默认地图中心点?
A: 在 `TiandituMap.vue` 组件中找到 `center` 属性并修改坐标
### Q: 如何添加更多图层?
A: 天地图还提供地形图等其他图层,可以参考官方文档进行配置
## 6. 相关链接
- [天地图官网](https://www.tianditu.gov.cn/)
- [天地图开发者控制台](https://console.tianditu.gov.cn/)
- [天地图API文档](https://lbs.tianditu.gov.cn/server/MapService.html)
- [ArcGIS API for JavaScript](https://developers.arcgis.com/javascript/latest/)