@naivemap/maplibre-gl-echarts-layer 0.0.1-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 +21 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +153 -0
- package/dist/index.umd.cjs +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +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.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ComposeOption, EffectScatterSeriesOption, LegendComponentOption, LinesSeriesOption, ScatterSeriesOption, TitleComponentOption, TooltipComponentOption } from 'echarts';
|
|
2
|
+
import { default as maplibregl } from 'maplibre-gl';
|
|
3
|
+
/**
|
|
4
|
+
* EChartsLayer 配置项
|
|
5
|
+
*/
|
|
6
|
+
export type ECOption = ComposeOption<TitleComponentOption | TooltipComponentOption | LegendComponentOption | LinesSeriesOption | ScatterSeriesOption | EffectScatterSeriesOption>;
|
|
7
|
+
/**
|
|
8
|
+
* EChartsLayer is a custom layer for MapLibre GL that integrates ECharts.
|
|
9
|
+
*/
|
|
10
|
+
export default class EChartsLayer implements maplibregl.CustomLayerInterface {
|
|
11
|
+
id: string;
|
|
12
|
+
/**
|
|
13
|
+
* 图层类型
|
|
14
|
+
* @ignore
|
|
15
|
+
*/
|
|
16
|
+
type: 'custom';
|
|
17
|
+
/**
|
|
18
|
+
* @ignore
|
|
19
|
+
*/
|
|
20
|
+
renderingMode?: '2d' | '3d' | undefined;
|
|
21
|
+
private _container;
|
|
22
|
+
private _map;
|
|
23
|
+
private _ec;
|
|
24
|
+
private _coordSystemName;
|
|
25
|
+
private _ecOption;
|
|
26
|
+
/**
|
|
27
|
+
* 构造函数,用于初始化 EChartsLayer 实例
|
|
28
|
+
* @param id - 图层 id
|
|
29
|
+
* @param ecOption - ECharts 的配置选项
|
|
30
|
+
*/
|
|
31
|
+
constructor(id: string, ecOption: ECOption);
|
|
32
|
+
/**
|
|
33
|
+
* @ignore
|
|
34
|
+
*/
|
|
35
|
+
onAdd(map: maplibregl.Map): void;
|
|
36
|
+
/**
|
|
37
|
+
* @ignore
|
|
38
|
+
*/
|
|
39
|
+
onRemove(): void;
|
|
40
|
+
/**
|
|
41
|
+
* 设置配置项
|
|
42
|
+
* @param option
|
|
43
|
+
*/
|
|
44
|
+
setOption(option: ECOption): void;
|
|
45
|
+
/**
|
|
46
|
+
* @ignore
|
|
47
|
+
*/
|
|
48
|
+
render(): void;
|
|
49
|
+
/**
|
|
50
|
+
* @ignore
|
|
51
|
+
*/
|
|
52
|
+
private _prepareECharts;
|
|
53
|
+
/**
|
|
54
|
+
* @ignore
|
|
55
|
+
*/
|
|
56
|
+
private _createLayerContainer;
|
|
57
|
+
/**
|
|
58
|
+
* @ignore
|
|
59
|
+
*/
|
|
60
|
+
private _removeLayerContainer;
|
|
61
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { getCoordinateSystemDimensions as p, registerCoordinateSystem as m, init as l } from "echarts";
|
|
2
|
+
const c = r;
|
|
3
|
+
function r(a, t) {
|
|
4
|
+
const x = o();
|
|
5
|
+
return r = function(e, n) {
|
|
6
|
+
return e = e - 241, x[e];
|
|
7
|
+
}, r(a, t);
|
|
8
|
+
}
|
|
9
|
+
(function(a, t) {
|
|
10
|
+
const x = { _0x23e5d9: 290, _0x3f1620: 293, _0x216574: 254, _0x4f9397: 266, _0x322c37: 271 }, e = r, n = a();
|
|
11
|
+
for (; ; )
|
|
12
|
+
try {
|
|
13
|
+
if (-parseInt(e(265)) / 1 + parseInt(e(x._0x23e5d9)) / 2 + parseInt(e(275)) / 3 * (-parseInt(e(282)) / 4) + parseInt(e(246)) / 5 + parseInt(e(x._0x3f1620)) / 6 + parseInt(e(x._0x216574)) / 7 * (parseInt(e(x._0x4f9397)) / 8) + parseInt(e(x._0x322c37)) / 9 * (parseInt(e(278)) / 10) === t) break;
|
|
14
|
+
n.push(n.shift());
|
|
15
|
+
} catch {
|
|
16
|
+
n.push(n.shift());
|
|
17
|
+
}
|
|
18
|
+
})(o, 141456);
|
|
19
|
+
const u = /* @__PURE__ */ function() {
|
|
20
|
+
let a = !0;
|
|
21
|
+
return function(t, x) {
|
|
22
|
+
const e = a ? function() {
|
|
23
|
+
if (x) {
|
|
24
|
+
const n = x.apply(t, arguments);
|
|
25
|
+
return x = null, n;
|
|
26
|
+
}
|
|
27
|
+
} : function() {
|
|
28
|
+
};
|
|
29
|
+
return a = !1, e;
|
|
30
|
+
};
|
|
31
|
+
}(), h = u(void 0, function() {
|
|
32
|
+
const a = { _0x2f699e: 294, _0xf5535b: 281 }, t = r, x = { Crzqp: t(242) };
|
|
33
|
+
return h[t(294)]().search(x[t(280)])[t(a._0x2f699e)]()[t(a._0xf5535b)](h).search(x[t(280)]);
|
|
34
|
+
});
|
|
35
|
+
function o() {
|
|
36
|
+
const a = ["onAdd", "1|0|2|4|3", "270006AooCIv", "toString", "_prepareECharts", "kNQZd", "resize", "_mapOffset", "setOption", "(((.+)+)+)+$", "renderingMode", "create", "eachSeries", "494140zRsDub", "unproject", "lng", "coordinateSystem", "getCanvas", "Hikti", "_map", "hlTTY", "21yCLBFm", "removeChild", "Uagfb", "BmDKL", "style", "split", "_ecOption", "div", "custom", "height", "_removeLayerContainer", "187012MTkkdf", "182128XyDEma", "length", "_container", "_createLayerContainer", "width", "54DSmZWC", "get", "fNkHe", "getCanvasContainer", "3sdMMDH", "render", "_ec", "237310VduYSB", "DGeVJ", "Crzqp", "constructor", "874024kAIvQJ", "type", "Pdajs", "clear", "pYMfU", "yBoJj", "_coordSystemName", "UyIOi", "384922mxbSqV"];
|
|
37
|
+
return o = function() {
|
|
38
|
+
return a;
|
|
39
|
+
}, o();
|
|
40
|
+
}
|
|
41
|
+
h();
|
|
42
|
+
const y = "maplibregl-echarts";
|
|
43
|
+
class d {
|
|
44
|
+
id;
|
|
45
|
+
dimensions = ["x", "y"];
|
|
46
|
+
[c(252)];
|
|
47
|
+
_mapOffset = [0, 0];
|
|
48
|
+
constructor(t, x) {
|
|
49
|
+
this.id = t, this._map = x;
|
|
50
|
+
}
|
|
51
|
+
[c(244)](t) {
|
|
52
|
+
const x = { _0xd7c942: 245 }, e = { _0x2e9752: 284, _0x29f7e6: 272 }, n = c, _ = { Pdajs: function(s, i) {
|
|
53
|
+
return s === i;
|
|
54
|
+
}, Hikti: n(249) };
|
|
55
|
+
t[n(x._0xd7c942)]((s) => {
|
|
56
|
+
const i = n;
|
|
57
|
+
_[i(e._0x2e9752)](s[i(e._0x29f7e6)](_[i(251)]), this.id) && (s[i(249)] = new d(this.id, this._map));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
dataToPoint(t) {
|
|
61
|
+
const x = { _0xcf3b8a: 289 }, e = c, n = { UyIOi: function(i, f) {
|
|
62
|
+
return i - f;
|
|
63
|
+
} }, _ = this[e(252)].project(t), s = this._mapOffset;
|
|
64
|
+
return [n[e(x._0xcf3b8a)](_.x, s[0]), n.UyIOi(_.y, s[1])];
|
|
65
|
+
}
|
|
66
|
+
pointToData(t) {
|
|
67
|
+
const x = { _0x35cabb: 273 }, e = c, n = { fNkHe: function(i, f) {
|
|
68
|
+
return i + f;
|
|
69
|
+
} }, _ = this[e(298)], s = this[e(252)][e(247)]([n[e(273)](t[0], _[0]), n[e(x._0x35cabb)](t[1], _[1])]);
|
|
70
|
+
return [s[e(248)], s.lat];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
class C {
|
|
74
|
+
id;
|
|
75
|
+
[c(283)];
|
|
76
|
+
renderingMode;
|
|
77
|
+
[c(268)];
|
|
78
|
+
[c(252)];
|
|
79
|
+
_ec;
|
|
80
|
+
_coordSystemName;
|
|
81
|
+
[c(260)];
|
|
82
|
+
constructor(t, x) {
|
|
83
|
+
const e = { _0x290523: 262, _0x3a5717: 259, _0x3123dd: 283, _0x17418b: 257, _0x207349: 279 }, n = c, _ = { yBoJj: n(292), BmDKL: n(e._0x290523), DGeVJ: function(f, b) {
|
|
84
|
+
return f + b;
|
|
85
|
+
} }, s = _[n(287)][n(e._0x3a5717)]("|");
|
|
86
|
+
let i = 0;
|
|
87
|
+
for (; ; ) {
|
|
88
|
+
switch (s[i++]) {
|
|
89
|
+
case "0":
|
|
90
|
+
this[n(e._0x3123dd)] = _[n(e._0x17418b)];
|
|
91
|
+
continue;
|
|
92
|
+
case "1":
|
|
93
|
+
this.id = t;
|
|
94
|
+
continue;
|
|
95
|
+
case "2":
|
|
96
|
+
this[n(243)] = "2d";
|
|
97
|
+
continue;
|
|
98
|
+
case "3":
|
|
99
|
+
this[n(260)] = x;
|
|
100
|
+
continue;
|
|
101
|
+
case "4":
|
|
102
|
+
this[n(288)] = _[n(279)](_[n(e._0x207349)](y, "-"), Math.random().toString(16).substring(2));
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
[c(291)](t) {
|
|
109
|
+
const x = { _0x2de920: 252 }, e = c, n = { nsABt: function(_, s) {
|
|
110
|
+
return _(s);
|
|
111
|
+
}, pYMfU: function(_, s, i) {
|
|
112
|
+
return _(s, i);
|
|
113
|
+
} };
|
|
114
|
+
if (this[e(252)] = t, this._createLayerContainer(), !n.nsABt(p, this[e(288)])) {
|
|
115
|
+
const _ = new d(this[e(288)], this[e(x._0x2de920)]);
|
|
116
|
+
n[e(286)](m, this._coordSystemName, _);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
onRemove() {
|
|
120
|
+
const t = { _0x42472a: 264 }, x = c;
|
|
121
|
+
this._ec?.dispose(), this[x(t._0x42472a)]();
|
|
122
|
+
}
|
|
123
|
+
[c(241)](t) {
|
|
124
|
+
const x = { _0x5b08bb: 241 }, e = c;
|
|
125
|
+
this[e(277)]?.[e(x._0x5b08bb)](t);
|
|
126
|
+
}
|
|
127
|
+
[c(276)]() {
|
|
128
|
+
const t = { _0x444ec5: 269, _0x2d3cbf: 268, _0x2f0be4: 295, _0x584136: 285, _0x5ea923: 297, _0x3af77b: 250, _0x2b8464: 277, _0x21238a: 241, _0x3bc6b6: 260 }, x = c, e = { hlTTY: function(n, _) {
|
|
129
|
+
return n(_);
|
|
130
|
+
} };
|
|
131
|
+
!this[x(268)] && this[x(t._0x444ec5)](), this[x(277)] ? this._map.isMoving() ? this[x(277)][x(t._0x584136)]() : (this[x(277)][x(t._0x5ea923)]({ width: this[x(252)][x(250)]().width, height: this[x(252)][x(t._0x3af77b)]()[x(263)] }), this[x(t._0x2b8464)][x(t._0x21238a)](this[x(t._0x3bc6b6)])) : (this[x(277)] = e[x(253)](l, this[x(t._0x2d3cbf)]), this[x(t._0x2f0be4)](), this[x(277)].setOption(this._ecOption));
|
|
132
|
+
}
|
|
133
|
+
[c(295)]() {
|
|
134
|
+
const t = { _0x5936fe: 256 }, x = c, e = { gDpnW: function(_, s) {
|
|
135
|
+
return _ - s;
|
|
136
|
+
}, kNQZd: function(_, s) {
|
|
137
|
+
return _ >= s;
|
|
138
|
+
}, Uagfb: "coordinateSystem" }, n = this._ecOption.series;
|
|
139
|
+
if (n) for (let _ = e.gDpnW(n[x(267)], 1); e[x(296)](_, 0); _--)
|
|
140
|
+
n[_][e[x(t._0x5936fe)]] = this[x(288)];
|
|
141
|
+
}
|
|
142
|
+
[c(269)]() {
|
|
143
|
+
const t = { _0xb7153e: 261, _0x22d553: 268, _0x401d55: 270, _0x5b4acf: 258, _0x3c92b2: 252, _0x43dc6e: 263 }, x = c, e = { RevXs: x(t._0xb7153e) }, n = this._map[x(274)]();
|
|
144
|
+
this[x(268)] = document.createElement(e.RevXs), this[x(t._0x22d553)][x(258)][x(t._0x401d55)] = this._map[x(250)]()[x(258)][x(t._0x401d55)], this[x(268)][x(t._0x5b4acf)][x(263)] = this[x(t._0x3c92b2)][x(250)]().style[x(t._0x43dc6e)], n.appendChild(this[x(t._0x22d553)]);
|
|
145
|
+
}
|
|
146
|
+
_removeLayerContainer() {
|
|
147
|
+
const t = { _0x48a86d: 268, _0x2a5eb3: 255 }, x = c;
|
|
148
|
+
this[x(268)] && this[x(t._0x48a86d)].parentNode?.[x(t._0x2a5eb3)](this._container);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
export {
|
|
152
|
+
C as default
|
|
153
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
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){this._ec?.setOption(t)}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});
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@naivemap/maplibre-gl-echarts-layer",
|
|
3
|
+
"version": "0.0.1-alpha.0",
|
|
4
|
+
"description": "Integrate the Lines graph and Scatter (bubble) chart of Apache ECharts",
|
|
5
|
+
"main": "./dist/index.umd.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.umd.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"maplibre",
|
|
19
|
+
"echarts",
|
|
20
|
+
"layer",
|
|
21
|
+
"custom"
|
|
22
|
+
],
|
|
23
|
+
"author": "naivemap",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"repository": "https://github.com/naivemap/maplibre-gl-layers",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"echarts": "^5.0.0",
|
|
32
|
+
"maplibre-gl": "^4.0.0 || ^5.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"echarts": "^5.6.0",
|
|
36
|
+
"maplibre-gl": "^5.6.1"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "vite build",
|
|
40
|
+
"docs:build": "pnpm typedoc"
|
|
41
|
+
}
|
|
42
|
+
}
|