tg-map-echarts 4.3.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -6,8 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
import * as echarts from 'echarts'
|
|
9
|
+
import type { ComposeOption, EffectScatterSeriesOption } from 'echarts'
|
|
9
10
|
import { type BaseMap, CoordType, GestureHandlingOptions, loadCachedMap, TgMapType } from 'tg-map-core'
|
|
10
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
TgMapExtension,
|
|
13
|
+
type TgMapComponentOption,
|
|
14
|
+
type TgMapSeriesOption,
|
|
15
|
+
} from 'tg-map-echarts'
|
|
16
|
+
|
|
17
|
+
type ECOption = ComposeOption<
|
|
18
|
+
TgMapComponentOption | TgMapSeriesOption<EffectScatterSeriesOption>
|
|
19
|
+
>
|
|
11
20
|
|
|
12
21
|
// 显式安装一次扩展;包本身不会修改全局ECharts实例。
|
|
13
22
|
echarts.use(TgMapExtension)
|
|
@@ -29,7 +38,7 @@ chart.setOption({
|
|
|
29
38
|
coordinateSystem: 'tgMap',
|
|
30
39
|
data: [[116.4, 39.9, 10]],
|
|
31
40
|
}],
|
|
32
|
-
})
|
|
41
|
+
} satisfies ECOption)
|
|
33
42
|
```
|
|
34
43
|
|
|
35
44
|
`dataCoordType` 默认为 `wgs84`。业务数据不需要预先转换为地图引擎使用的坐标系,扩展会将 ECharts 的 `[lng, lat, ...]` 数据包装为 `LatLng` 后交给 `tg-map-core` 转换。
|
|
@@ -34,7 +34,7 @@ export default class TgMapModel extends ComponentModel<ResolvedTgMapComponentOpt
|
|
|
34
34
|
private runtime?;
|
|
35
35
|
getEngine(): TgMapType;
|
|
36
36
|
getDataCoordType(): CoordType;
|
|
37
|
-
getMapOptions(): Omit<import("tg-map-core").MapOptions, "
|
|
37
|
+
getMapOptions(): Omit<import("tg-map-core").MapOptions, "center" | "mapStyle"> & {
|
|
38
38
|
center: import("tg-map-core").LatLngLiteral;
|
|
39
39
|
mapStyle?: string;
|
|
40
40
|
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { ComponentModel, registerCoordinateSystem, SeriesModel, use } from 'echarts/core';
|
|
2
2
|
import type { CoordType, DeepPartial, LatLngLiteral, MapOptions, TgMapType } from 'tg-map-core';
|
|
3
3
|
export type TgMapComponentOption = DeepPartial<ResolvedTgMapComponentOption>;
|
|
4
|
+
/** 将使用tgMap坐标系的Series类型适配为coordinateSystem: 'tgMap'。 */
|
|
5
|
+
export type TgMapSeriesOption<Option extends SeriesOption> = Option extends SeriesOption ? Omit<Option, 'coordinateSystem'> & {
|
|
6
|
+
coordinateSystem: 'tgMap';
|
|
7
|
+
} : never;
|
|
4
8
|
/**
|
|
5
9
|
* 参考maptalks, 所有自定义的必选字段都通过`defaultOption`设置默认值, 外部设置option时, 全部字段都可选, 这样在读取的时候, 就可以省略判空
|
|
6
10
|
* 注意, 如果用户主动将字段设为null/undefined, 字段依然会读到null/undefined, 而不是默认值
|
|
@@ -34,5 +38,6 @@ export type ExtensionAPI = CoordinateSystemCreatorParameters[1];
|
|
|
34
38
|
export type GlobalModel = CoordinateSystemCreatorParameters[0];
|
|
35
39
|
export type CoordinateSystem = SeriesModel['coordinateSystem'];
|
|
36
40
|
export type ComponentOption = ComponentModel['option'];
|
|
41
|
+
export type SeriesOption = SeriesModel['option'];
|
|
37
42
|
export {};
|
|
38
43
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/index.d.ts
CHANGED
package/dist/tg-map-echarts.cjs
CHANGED
|
@@ -153,7 +153,6 @@ class TgMapCoordSys {
|
|
|
153
153
|
else {
|
|
154
154
|
runtime = TgMapCoordSys.createMapRuntime(model, api);
|
|
155
155
|
}
|
|
156
|
-
console.log('TgMapCoordSys.create', runtime);
|
|
157
156
|
coordinateSystem = new TgMapCoordSys(runtime.map, api, model.getDataCoordType());
|
|
158
157
|
model.coordinateSystem = coordinateSystem;
|
|
159
158
|
});
|
|
@@ -314,7 +313,6 @@ class TgMapView extends core.ComponentView {
|
|
|
314
313
|
this.bindMapEvents(runtime, api);
|
|
315
314
|
}
|
|
316
315
|
model.applyUIOptions(runtime);
|
|
317
|
-
console.log('TgMapView.render', runtime);
|
|
318
316
|
runtime.syncViewportPosition();
|
|
319
317
|
}
|
|
320
318
|
finally {
|
package/dist/tg-map-echarts.mjs
CHANGED
|
@@ -151,7 +151,6 @@ class TgMapCoordSys {
|
|
|
151
151
|
else {
|
|
152
152
|
runtime = TgMapCoordSys.createMapRuntime(model, api);
|
|
153
153
|
}
|
|
154
|
-
console.log('TgMapCoordSys.create', runtime);
|
|
155
154
|
coordinateSystem = new TgMapCoordSys(runtime.map, api, model.getDataCoordType());
|
|
156
155
|
model.coordinateSystem = coordinateSystem;
|
|
157
156
|
});
|
|
@@ -312,7 +311,6 @@ class TgMapView extends ComponentView {
|
|
|
312
311
|
this.bindMapEvents(runtime, api);
|
|
313
312
|
}
|
|
314
313
|
model.applyUIOptions(runtime);
|
|
315
|
-
console.log('TgMapView.render', runtime);
|
|
316
314
|
runtime.syncViewportPosition();
|
|
317
315
|
}
|
|
318
316
|
finally {
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
pnpm add echarts tg-map-core tg-map-echarts
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
`tg-map-echarts` 的版本号与 `tg-map-core` 保持一致,建议安装相同的明确版本,避免加载两份不同版本的 `tg-map-core`。以 `4.
|
|
28
|
+
`tg-map-echarts` 的版本号与 `tg-map-core` 保持一致,建议安装相同的明确版本,避免加载两份不同版本的 `tg-map-core`。以 `4.3.1` 为例:
|
|
29
29
|
|
|
30
30
|
```sh
|
|
31
|
-
pnpm add tg-map-core@4.
|
|
31
|
+
pnpm add tg-map-core@4.3.1 tg-map-echarts@4.3.1
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
如果项目使用的 tg-map Vue 组件库已经重新导出了同一版本的 `tg-map-core`,可以继续从 Vue 组件库导入公共地图类型和工具;但 `tg-map-echarts` 仍需单独安装。可以通过 `pnpm why tg-map-core` 确认项目只解析到兼容版本;如果存在多个模块实例,从 Vue 插件写入的地图配置可能无法被 `tg-map-echarts` 依赖的实例读取。
|
|
@@ -72,6 +72,49 @@ echarts.use([
|
|
|
72
72
|
])
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
### TypeScript 类型提示
|
|
76
|
+
|
|
77
|
+
使用 ECharts 官方的 `ComposeOption` 组合实际用到的组件和系列类型。`TgMapComponentOption` 描述顶层 `tgMap` 组件;`TgMapSeriesOption<T>` 将内置系列的 `coordinateSystem` 适配为 `'tgMap'`:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import * as echarts from 'echarts'
|
|
81
|
+
import type {
|
|
82
|
+
ComposeOption,
|
|
83
|
+
EffectScatterSeriesOption,
|
|
84
|
+
HeatmapSeriesOption,
|
|
85
|
+
} from 'echarts'
|
|
86
|
+
import { CoordType, TgMapType } from 'tg-map-core'
|
|
87
|
+
import {
|
|
88
|
+
TgMapExtension,
|
|
89
|
+
type TgMapComponentOption,
|
|
90
|
+
type TgMapSeriesOption,
|
|
91
|
+
} from 'tg-map-echarts'
|
|
92
|
+
|
|
93
|
+
type ECOption = ComposeOption<
|
|
94
|
+
| TgMapComponentOption
|
|
95
|
+
| TgMapSeriesOption<HeatmapSeriesOption | EffectScatterSeriesOption>
|
|
96
|
+
>
|
|
97
|
+
|
|
98
|
+
echarts.use(TgMapExtension)
|
|
99
|
+
|
|
100
|
+
chart.setOption({
|
|
101
|
+
tgMap: {
|
|
102
|
+
engine: TgMapType.baidu,
|
|
103
|
+
mapOptions: {
|
|
104
|
+
center: { lng: 113.2644, lat: 23.1291, coord: CoordType.wgs84 },
|
|
105
|
+
zoom: 14,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
series: [{
|
|
109
|
+
type: 'heatmap',
|
|
110
|
+
coordinateSystem: 'tgMap',
|
|
111
|
+
data: points,
|
|
112
|
+
}],
|
|
113
|
+
} satisfies ECOption)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`TgMapSeriesOption<T>` 是分布式条件类型,可以一次传入多个系列类型。使用 `echarts/core` 按需引入时写法相同,只需从 `echarts/charts` 和 `echarts/components` 导入对应的 option 类型。
|
|
117
|
+
|
|
75
118
|
## 3. 配置并加载地图引擎
|
|
76
119
|
|
|
77
120
|
在创建图表前,先配置 `tg-map-core`。如果应用已经通过 tg-map 的 Vue 插件传入地图配置,则不需要重复调用 `setTgMapConfig`。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tg-map-echarts",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"author": "ipcjs",
|
|
5
5
|
"description": "基于 tg-map-core 的 ECharts 地图坐标系扩展",
|
|
6
6
|
"keywords": [
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"tg-commons": "^1.2.12",
|
|
38
|
-
"tg-map-core": "4.3.
|
|
38
|
+
"tg-map-core": "4.3.1"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"echarts": "^5.2.1"
|