主题
安装
私有源配置
GMap SDK 托管在内部私有 npm 仓库,使用前需配置对应环境的源地址。
厅政务外网
bash
npm config set @gmap:registry https://npm.szwt.gov.cn厅互联网
bash
npm config set @gmap:registry https://npm.szinw.gov.cn企业政务外网
bash
npm config set @gmap:registry https://npm.qywt.gov.cn企业互联网
bash
npm config set @gmap:registry https://npm.qyinw.gov.cn或在 .npmrc 中配置
ini
@gmap:registry=https://npm.szwt.gov.cn
//npm.szwt.gov.cn/:_authToken=${NPM_TOKEN}包管理器安装
npm
bash
npm install @gmap/core @gmap/standard @gmap/shim-openlayersyarn
bash
yarn add @gmap/core @gmap/standard @gmap/shim-openlayerspnpm
bash
pnpm add @gmap/core @gmap/standard @gmap/shim-openlayers按需安装
核心包(必选)
bash
npm install @gmap/coreAPI 层(三选一或组合使用)
bash
npm install @gmap/simple # 简易版:零 new,链式调用
npm install @gmap/standard # 标准版:ES 模块,完整类型
npm install @gmap/advanced # 专业版:门面子模式引擎适配器(按需选择)
bash
npm install @gmap/shim-openlayers ol # OpenLayers 2D
npm install @gmap/shim-maplibre maplibre-gl # MapLibre 矢量瓦片
npm install @gmap/shim-cesium cesium # Cesium 3D插件
bash
npm install @gmap/services # 地图服务 API(地理编码/POI/路径/天气)
npm install @gmap/geo # 量算/分析/坐标投影
npm install @gmap/style-mapbox # Mapbox 样式引擎一次性安装全部
bash
npm install @gmap/core @gmap/geo @gmap/style-mapbox @gmap/standard @gmap/simple @gmap/advanced @gmap/shim-openlayers @gmap/shim-maplibre @gmap/shim-cesium @gmap/services包说明
| 包名 | 说明 | 依赖 |
|---|---|---|
@gmap/core | 核心抽象层 | 无 |
@gmap/geo | 量算/分析/投影 | 无 |
@gmap/style-mapbox | Mapbox 样式引擎 | 无 |
@gmap/standard | 标准版 API | core, geo |
@gmap/simple | 简易版 API | core, geo, standard, services |
@gmap/advanced | 专业版 API | core, geo, standard, services |
@gmap/shim-openlayers | OpenLayers 适配器 | core (peer: ol) |
@gmap/shim-maplibre | MapLibre 适配器 | core, style-mapbox (peer: maplibre-gl) |
@gmap/shim-cesium | Cesium 适配器 | core (peer: cesium) |
@gmap/services | 地图服务 | 无 |
TypeScript 配置
json
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "NodeNext",
"target": "ES2022",
"strict": true
}
}浏览器兼容性
| 浏览器 | 最低版本 |
|---|---|
| Chrome | 80+ |
| Firefox | 78+ |
| Safari | 14+ |
| Edge | 80+ |
验证安装
ts
import { EngineRegistry, MockAdapter } from '@gmap/core';
EngineRegistry.register('mock', () => new MockAdapter(), { default: '2d' });
console.log('GMap SDK 安装成功');