@naivemap/maplibre-gl-echarts-layer 0.1.0 → 0.2.0-alpha.0

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Naive Map
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Naive Map
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # @naivemap/maplibre-gl-echarts-layer
2
-
3
- EChartsLayer ([@naivemap/maplibre-gl-echarts-layer](https://www.npmjs.com/package/@naivemap/maplibre-gl-echarts-layer)): Integrates Apache ECharts with MapLibre GL JS, specifically enabling the use of **Lines graphs** and **Scatter (bubble)** charts as a map layer. This allows for visualizing connections, paths, and point-based data with the rich styling capabilities of ECharts.
4
-
5
- [API References](https://www.naivemap.com/maplibre-gl-layers/api/echarts-layer/)
6
-
7
- ## Install
8
-
9
- ```bash
10
- pnpm add @naivemap/maplibre-gl-echarts-layer echarts
11
- ```
1
+ # @naivemap/maplibre-gl-echarts-layer
2
+
3
+ EChartsLayer ([@naivemap/maplibre-gl-echarts-layer](https://www.npmjs.com/package/@naivemap/maplibre-gl-echarts-layer)): Integrates Apache ECharts with MapLibre GL JS, specifically enabling the use of **Lines graphs** and **Scatter (bubble)** charts as a map layer. This allows for visualizing connections, paths, and point-based data with the rich styling capabilities of ECharts.
4
+
5
+ [API References](https://www.naivemap.com/maplibre-gl-layers/api/maplibre-gl-echarts-layer/)
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @naivemap/maplibre-gl-echarts-layer echarts
11
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";const t=require("@naivemap/echarts-layer-core"),o=require("@naivemap/map-gl-layer-adaptor");class s{id;type;renderingMode;_core;_adaptor;constructor(e,r){this.id=e,this.type="custom",this.renderingMode="2d",this._core=new t(r),this._adaptor=o.createMapLibreLayerAdaptor(this._core,{id:e,renderingMode:this.renderingMode})}onAdd(e,r){this._adaptor.onAdd(e,r)}onRemove(e,r){this._adaptor.onRemove(e,r)}setOption(e,r){this._core.setOption(e,r)}render(e,r){this._adaptor.render(e,r)}}module.exports=s;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
- import { default as EChartsLayer } from './EChartsLayer';
2
- export type { ECOption } from './EChartsLayer';
3
- export default EChartsLayer;
1
+ export * from './maplibre-gl-echarts-layer/src/index'
2
+ export {}
3
+ import EChartsLayer from './maplibre-gl-echarts-layer/src/index'
4
+ export default EChartsLayer
5
+ export * from './maplibre-gl-echarts-layer/src/index'
6
+ export {}
package/dist/index.js CHANGED
@@ -1,158 +1,60 @@
1
- import { getCoordinateSystemDimensions as p, registerCoordinateSystem as m, init as l } from "echarts";
2
- function r(i, t) {
3
- const x = o();
4
- return r = function(e, _) {
5
- return e = e - 224, x[e];
6
- }, r(i, t);
7
- }
8
- function o() {
9
- const i = ["render", "project", "2|1|0|3|4", "isMoving", "width", "_coordSystemName", "length", "AahOj", "_prepareECharts", "apply", "split", "(((.+)+)+)+$", "_container", "lat", "series", "pointToData", "291772lPDZXS", "GOsgX", "_mapOffset", "getCanvasContainer", "unproject", "qhkgu", "689079IRHymf", "resize", "get", "dIzPr", "_createLayerContainer", "height", "_ec", "_ecOption", "constructor", "sYjhy", "create", "temDW", "dispose", "lng", "19488352RZTPFo", "renderingMode", "toString", "7700120jwSfap", "removeChild", "style", "getCanvas", "AObut", "dimensions", "380055ZZhKbX", "jagNs", "JQxpV", "kbosd", "1806070sfIyDw", "search", "dataToPoint", "coordinateSystem", "onRemove", "div", "substring", "onAdd", "knxrt", "9846420jFGSOz", "setOption", "LfjDd", "parentNode", "type", "2FsNvYb", "_removeLayerContainer", "RYmSC", "_map", "random"];
10
- return o = function() {
11
- return i;
12
- }, o();
13
- }
14
- const c = r;
15
- (function(i, t) {
16
- const x = { _0x4ce361: 253, _0x3dedf7: 247, _0x5eb008: 270, _0x37281f: 280 }, e = r, _ = i();
17
- for (; ; )
18
- try {
19
- if (-parseInt(e(276)) / 1 + parseInt(e(226)) / 2 * (parseInt(e(x._0x4ce361)) / 3) + parseInt(e(x._0x3dedf7)) / 4 + parseInt(e(x._0x5eb008)) / 5 + parseInt(e(289)) / 6 + parseInt(e(x._0x37281f)) / 7 + -parseInt(e(267)) / 8 === t) break;
20
- _.push(_.shift());
21
- } catch {
22
- _.push(_.shift());
23
- }
24
- })(o, 925641);
25
- const u = /* @__PURE__ */ function() {
26
- let i = !0;
27
- return function(t, x) {
28
- const e = i ? function() {
29
- const _ = r;
30
- if (x) {
31
- const n = x[_(240)](t, arguments);
32
- return x = null, n;
33
- }
34
- } : function() {
35
- };
36
- return i = !1, e;
37
- };
38
- }(), h = u(void 0, function() {
39
- const i = { _0x29537a: 269, _0x58c935: 278, _0x1c7685: 261, _0xe28cc7: 281 }, t = r, x = { JQxpV: t(242) };
40
- return h[t(i._0x29537a)]().search(x[t(i._0x58c935)])[t(i._0x29537a)]()[t(i._0x1c7685)](h)[t(i._0xe28cc7)](x.JQxpV);
41
- });
42
- h();
43
- const g = "maplibregl-echarts";
44
- class b {
1
+ import t from "@naivemap/echarts-layer-core";
2
+ import { createMapLibreLayerAdaptor as o } from "@naivemap/map-gl-layer-adaptor";
3
+ class s {
45
4
  id;
46
- [c(275)] = ["x", "y"];
47
- [c(229)];
48
- _mapOffset = [0, 0];
49
- constructor(t, x) {
50
- const e = c;
51
- this.id = t, this[e(229)] = x;
52
- }
53
- [c(263)](t) {
54
- const x = { _0x2bc2ed: 288 }, e = c, _ = { knxrt: function(n, s) {
55
- return n === s;
56
- }, YzlBK: e(283) };
57
- t.eachSeries((n) => {
58
- const s = e;
59
- _[s(x._0x2bc2ed)](n[s(255)](_.YzlBK), this.id) && (n[s(283)] = new b(this.id, this[s(229)]));
5
+ /**
6
+ * @ignore
7
+ */
8
+ type;
9
+ /**
10
+ * @ignore
11
+ */
12
+ renderingMode;
13
+ _core;
14
+ _adaptor;
15
+ /**
16
+ * @param id - A unique layer id
17
+ * @param ecOption - The ECharts option object used to configure the visualization.
18
+ * @see https://echarts.apache.org/en/option.html
19
+ */
20
+ constructor(e, r) {
21
+ this.id = e, this.type = "custom", this.renderingMode = "2d", this._core = new t(r), this._adaptor = o(this._core, {
22
+ id: e,
23
+ renderingMode: this.renderingMode
60
24
  });
61
25
  }
62
- [c(282)](t) {
63
- const x = { _0x5d94b4: 229, _0x21d0d5: 249, _0x4b510c: 238 }, e = c, _ = { AahOj: function(a, f) {
64
- return a - f;
65
- } }, n = this[e(x._0x5d94b4)][e(232)](t), s = this[e(x._0x21d0d5)];
66
- return [_[e(x._0x4b510c)](n.x, s[0]), _.AahOj(n.y, s[1])];
67
- }
68
- [c(246)](t) {
69
- const x = c, e = { yAZXc: function(s, a) {
70
- return s + a;
71
- }, aHVXM: function(s, a) {
72
- return s + a;
73
- } }, _ = this._mapOffset, n = this[x(229)][x(251)]([e.yAZXc(t[0], _[0]), e.aHVXM(t[1], _[1])]);
74
- return [n[x(266)], n[x(244)]];
75
- }
76
- }
77
- class O {
78
- id;
79
- [c(225)];
80
- [c(268)];
81
- _container;
82
- [c(229)];
83
- [c(259)];
84
- [c(236)];
85
- _ecOption;
86
- constructor(t, x) {
87
- const e = { _0x11b415: 256, _0x35bebc: 241, _0x2beb0a: 268, _0x46fbcd: 264 }, _ = c, n = { dIzPr: _(233), svGWO: "custom", temDW: function(f, d) {
88
- return f + d;
89
- }, AObut: function(f, d) {
90
- return f + d;
91
- } }, s = n[_(e._0x11b415)][_(e._0x35bebc)]("|");
92
- let a = 0;
93
- for (; ; ) {
94
- switch (s[a++]) {
95
- case "0":
96
- this[_(e._0x2beb0a)] = "2d";
97
- continue;
98
- case "1":
99
- this[_(225)] = n.svGWO;
100
- continue;
101
- case "2":
102
- this.id = t;
103
- continue;
104
- case "3":
105
- this._coordSystemName = n[_(e._0x46fbcd)](n[_(274)](g, "-"), Math[_(230)]()[_(269)](16)[_(286)](2));
106
- continue;
107
- case "4":
108
- this._ecOption = x;
109
- continue;
110
- }
111
- break;
112
- }
113
- }
114
- [c(287)](t) {
115
- const x = { _0x494f35: 229, _0x2a74fd: 236, _0x4c38c2: 236 }, e = c, _ = { LfjDd: function(n, s) {
116
- return n(s);
117
- }, GOsgX: function(n, s, a) {
118
- return n(s, a);
119
- } };
120
- if (this[e(x._0x494f35)] = t, this[e(257)](), !_[e(291)](p, this[e(x._0x2a74fd)])) {
121
- const n = new b(this[e(x._0x2a74fd)], this[e(x._0x494f35)]);
122
- _[e(248)](m, this[e(x._0x4c38c2)], n);
123
- }
124
- }
125
- [c(284)]() {
126
- const t = { _0x2df32d: 265 }, x = c;
127
- this._ec?.[x(t._0x2df32d)](), this[x(227)]();
128
- }
129
- setOption(t, x) {
130
- this._ec?.setOption(t, x);
131
- }
132
- [c(231)]() {
133
- const t = { _0x412dab: 257, _0x36df60: 259, _0x3a2f40: 252, _0x584cfe: 259, _0x3503e0: 229, _0x4f3fb8: 234, _0x53c7f3: 259, _0x1963b2: 259, _0x4bf6fb: 254, _0x340c63: 229, _0x27a5ef: 235, _0x345038: 273, _0x289605: 259 }, x = c, e = { qhkgu: function(_, n) {
134
- return _(n);
135
- } };
136
- !this._container && this[x(t._0x412dab)](), this[x(t._0x36df60)] ? this[x(t._0x3503e0)][x(t._0x4f3fb8)]() ? this[x(t._0x53c7f3)].clear() : (this[x(t._0x1963b2)][x(t._0x4bf6fb)]({ width: this[x(t._0x340c63)][x(273)]()[x(t._0x27a5ef)], height: this[x(229)][x(t._0x345038)]().height }), this[x(t._0x289605)].setOption(this[x(260)])) : (this[x(259)] = e[x(t._0x3a2f40)](l, this._container), this._prepareECharts(), this[x(t._0x584cfe)][x(290)](this[x(260)]));
137
- }
138
- [c(239)]() {
139
- const t = { _0x515dcc: 277, _0x49035a: 262, _0x3df600: 236 }, x = c, e = { jagNs: function(n, s) {
140
- return n - s;
141
- }, kbosd: function(n, s) {
142
- return n >= s;
143
- }, sYjhy: "coordinateSystem" }, _ = this[x(260)][x(245)];
144
- if (_) for (let n = e[x(t._0x515dcc)](_[x(237)], 1); e[x(279)](n, 0); n--)
145
- _[n][e[x(t._0x49035a)]] = this[x(t._0x3df600)];
146
- }
147
- [c(257)]() {
148
- const t = { _0x591bf8: 229, _0x281234: 243, _0x2e77a2: 235, _0xda316: 273, _0x3a53b0: 272, _0x384d1e: 229, _0x3becc9: 258 }, x = c, e = { RYmSC: x(285) }, _ = this[x(t._0x591bf8)][x(250)]();
149
- this[x(243)] = document.createElement(e[x(228)]), this[x(t._0x281234)][x(272)][x(t._0x2e77a2)] = this[x(229)][x(t._0xda316)]()[x(t._0x3a53b0)].width, this[x(243)].style[x(258)] = this[x(t._0x384d1e)].getCanvas()[x(272)][x(t._0x3becc9)], _.appendChild(this[x(243)]);
150
- }
151
- _removeLayerContainer() {
152
- const t = { _0x17c978: 224, _0x144b9b: 271 }, x = c;
153
- this._container && this[x(243)][x(t._0x17c978)]?.[x(t._0x144b9b)](this._container);
26
+ /**
27
+ * @ignore
28
+ */
29
+ onAdd(e, r) {
30
+ this._adaptor.onAdd(e, r);
31
+ }
32
+ /**
33
+ * @ignore
34
+ */
35
+ onRemove(e, r) {
36
+ this._adaptor.onRemove(e, r);
37
+ }
38
+ /**
39
+ * Updates the ECharts visualization with a new configuration.
40
+ * This is the primary method for dynamically changing the displayed data or styles.
41
+ *
42
+ * @param option - The new ECharts option object to apply.
43
+ * @param notMerge - If true, the new options will completely replace the existing ones.
44
+ * If false or undefined, the new options will be merged with the old ones.
45
+ * Defaults to `false`.
46
+ * @see https://echarts.apache.org/en/api.html#echartsInstance.setOption
47
+ */
48
+ setOption(e, r) {
49
+ this._core.setOption(e, r);
50
+ }
51
+ /**
52
+ * @ignore
53
+ */
54
+ render(e, r) {
55
+ this._adaptor.render(e, r);
154
56
  }
155
57
  }
156
58
  export {
157
- O as default
59
+ s as default
158
60
  };
@@ -1,10 +1,5 @@
1
- import { ComposeOption, EffectScatterSeriesOption, LegendComponentOption, LinesSeriesOption, ScatterSeriesOption, TitleComponentOption, TooltipComponentOption } from 'echarts';
2
- import { default as maplibregl } from 'maplibre-gl';
3
- /**
4
- * A composite type for ECharts options used by the EChartsLayer.
5
- * It includes common components and series types like Lines and Scatter.
6
- */
7
- export type ECOption = ComposeOption<TitleComponentOption | TooltipComponentOption | LegendComponentOption | LinesSeriesOption | ScatterSeriesOption | EffectScatterSeriesOption>;
1
+ import { ECOption } from '../../echarts-layer-core/src/index.ts';
2
+ import { CustomLayerInterface, Map } from 'maplibre-gl';
8
3
  /**
9
4
  * A custom MapLibre GL JS layer that renders Apache ECharts visualizations.
10
5
  *
@@ -42,7 +37,7 @@ export type ECOption = ComposeOption<TitleComponentOption | TooltipComponentOpti
42
37
  * map.addLayer(layer);
43
38
  * ```
44
39
  */
45
- export default class EChartsLayer implements maplibregl.CustomLayerInterface {
40
+ export default class EChartsLayer implements CustomLayerInterface {
46
41
  id: string;
47
42
  /**
48
43
  * @ignore
@@ -52,11 +47,8 @@ export default class EChartsLayer implements maplibregl.CustomLayerInterface {
52
47
  * @ignore
53
48
  */
54
49
  renderingMode?: '2d' | '3d' | undefined;
55
- private _container;
56
- private _map;
57
- private _ec;
58
- private _coordSystemName;
59
- private _ecOption;
50
+ private _core;
51
+ private _adaptor;
60
52
  /**
61
53
  * @param id - A unique layer id
62
54
  * @param ecOption - The ECharts option object used to configure the visualization.
@@ -66,11 +58,11 @@ export default class EChartsLayer implements maplibregl.CustomLayerInterface {
66
58
  /**
67
59
  * @ignore
68
60
  */
69
- onAdd(map: maplibregl.Map): void;
61
+ onAdd(map: Map, gl: WebGLRenderingContext): void;
70
62
  /**
71
63
  * @ignore
72
64
  */
73
- onRemove(): void;
65
+ onRemove(map: Map, gl: WebGLRenderingContext): void;
74
66
  /**
75
67
  * Updates the ECharts visualization with a new configuration.
76
68
  * This is the primary method for dynamically changing the displayed data or styles.
@@ -85,17 +77,5 @@ export default class EChartsLayer implements maplibregl.CustomLayerInterface {
85
77
  /**
86
78
  * @ignore
87
79
  */
88
- render(): void;
89
- /**
90
- * @ignore
91
- */
92
- private _prepareECharts;
93
- /**
94
- * @ignore
95
- */
96
- private _createLayerContainer;
97
- /**
98
- * @ignore
99
- */
100
- private _removeLayerContainer;
80
+ render(gl: WebGLRenderingContext, args: unknown): void;
101
81
  }
@@ -0,0 +1,3 @@
1
+ import { default as EChartsLayer } from './EChartsLayer';
2
+ export type { ECOption } from '../../echarts-layer-core/src/index.ts';
3
+ export default EChartsLayer;
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@naivemap/maplibre-gl-echarts-layer",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-alpha.0",
4
4
  "description": "A MapLibre GL JS layer to integrate Apache ECharts' Lines and Scatter charts.",
5
- "main": "./dist/index.umd.cjs",
5
+ "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "type": "module",
8
8
  "exports": {
9
9
  ".": {
10
+ "types": "./dist/index.d.ts",
10
11
  "import": "./dist/index.js",
11
- "require": "./dist/index.umd.cjs"
12
+ "require": "./dist/index.cjs"
12
13
  }
13
14
  },
14
15
  "files": [
@@ -27,6 +28,11 @@
27
28
  "publishConfig": {
28
29
  "access": "public"
29
30
  },
31
+ "sideEffects": false,
32
+ "dependencies": {
33
+ "@naivemap/map-gl-layer-adaptor": "0.1.0",
34
+ "@naivemap/echarts-layer-core": "0.1.0"
35
+ },
30
36
  "peerDependencies": {
31
37
  "echarts": "^5.0.0",
32
38
  "maplibre-gl": "^4.0.0 || ^5.0.0"
@@ -1 +0,0 @@
1
- (function(i,s){typeof exports=="object"&&typeof module<"u"?module.exports=s(require("echarts")):typeof define=="function"&&define.amd?define(["echarts"],s):(i=typeof globalThis<"u"?globalThis:i||self,i.EChartsLayer=s(i.echarts))})(this,function(i){"use strict";const s="maplibregl-echarts";class o{id;dimensions=["x","y"];_map;_mapOffset=[0,0];constructor(t,e){this.id=t,this._map=e}create(t){t.eachSeries(e=>{e.get("coordinateSystem")===this.id&&(e.coordinateSystem=new o(this.id,this._map))})}dataToPoint(t){const e=this._map.project(t),n=this._mapOffset;return[e.x-n[0],e.y-n[1]]}pointToData(t){const e=this._mapOffset,n=this._map.unproject([t[0]+e[0],t[1]+e[1]]);return[n.lng,n.lat]}}class a{id;type;renderingMode;_container;_map;_ec;_coordSystemName;_ecOption;constructor(t,e){this.id=t,this.type="custom",this.renderingMode="2d",this._coordSystemName=s+"-"+Math.random().toString(16).substring(2),this._ecOption=e}onAdd(t){if(this._map=t,this._createLayerContainer(),!i.getCoordinateSystemDimensions(this._coordSystemName)){const e=new o(this._coordSystemName,this._map);i.registerCoordinateSystem(this._coordSystemName,e)}}onRemove(){this._ec?.dispose(),this._removeLayerContainer()}setOption(t,e){this._ec?.setOption(t,e)}render(){this._container||this._createLayerContainer(),this._ec?this._map.isMoving()?this._ec.clear():(this._ec.resize({width:this._map.getCanvas().width,height:this._map.getCanvas().height}),this._ec.setOption(this._ecOption)):(this._ec=i.init(this._container),this._prepareECharts(),this._ec.setOption(this._ecOption))}_prepareECharts(){const t=this._ecOption.series;if(t)for(let e=t.length-1;e>=0;e--)t[e].coordinateSystem=this._coordSystemName}_createLayerContainer(){const t=this._map.getCanvasContainer();this._container=document.createElement("div"),this._container.style.width=this._map.getCanvas().style.width,this._container.style.height=this._map.getCanvas().style.height,t.appendChild(this._container)}_removeLayerContainer(){this._container&&this._container.parentNode?.removeChild(this._container)}}return a});