@naivemap/mapbox-gl-echarts-layer 0.3.2 → 0.3.3
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/dist/es/index.js +13 -14
- package/dist/js/index.d.ts +0 -1
- package/dist/js/index.js +12 -13
- package/package.json +2 -2
package/dist/es/index.js
CHANGED
|
@@ -1,43 +1,47 @@
|
|
|
1
|
-
import { init, registerCoordinateSystem, } from 'echarts';
|
|
1
|
+
import { init, registerCoordinateSystem, getCoordinateSystemDimensions, } from 'echarts';
|
|
2
2
|
var COORDINATE_SYSTEM_NAME = 'mapboxgl-echarts';
|
|
3
3
|
var CoordinateSystem = /** @class */ (function () {
|
|
4
|
-
function CoordinateSystem(map) {
|
|
4
|
+
function CoordinateSystem(id, map) {
|
|
5
5
|
this.dimensions = ['x', 'y'];
|
|
6
6
|
this._mapOffset = [0, 0];
|
|
7
|
-
this.
|
|
7
|
+
this.id = id;
|
|
8
|
+
this._map = map;
|
|
8
9
|
}
|
|
9
10
|
CoordinateSystem.prototype.create = function (ecModel) {
|
|
10
11
|
var _this = this;
|
|
11
12
|
ecModel.eachSeries(function (seriesModel) {
|
|
12
|
-
if (seriesModel.get('coordinateSystem') ===
|
|
13
|
-
seriesModel.coordinateSystem = new CoordinateSystem(_this.
|
|
13
|
+
if (seriesModel.get('coordinateSystem') === _this.id) {
|
|
14
|
+
seriesModel.coordinateSystem = new CoordinateSystem(_this.id, _this._map);
|
|
14
15
|
}
|
|
15
16
|
});
|
|
16
17
|
};
|
|
17
18
|
CoordinateSystem.prototype.dataToPoint = function (data) {
|
|
18
|
-
var px = this.
|
|
19
|
+
var px = this._map.project(data);
|
|
19
20
|
var mapOffset = this._mapOffset;
|
|
20
21
|
return [px.x - mapOffset[0], px.y - mapOffset[1]];
|
|
21
22
|
};
|
|
22
23
|
CoordinateSystem.prototype.pointToData = function (pt) {
|
|
23
24
|
var mapOffset = this._mapOffset;
|
|
24
|
-
var data = this.
|
|
25
|
+
var data = this._map.unproject([pt[0] + mapOffset[0], pt[1] + mapOffset[1]]);
|
|
25
26
|
return [data.lng, data.lat];
|
|
26
27
|
};
|
|
27
28
|
return CoordinateSystem;
|
|
28
29
|
}());
|
|
29
30
|
var EChartsLayer = /** @class */ (function () {
|
|
30
31
|
function EChartsLayer(id, ecOption) {
|
|
31
|
-
this._registered = false;
|
|
32
32
|
this.id = id;
|
|
33
33
|
this.type = 'custom';
|
|
34
34
|
this.renderingMode = '2d';
|
|
35
|
-
this._coordSystemName = COORDINATE_SYSTEM_NAME;
|
|
35
|
+
this._coordSystemName = COORDINATE_SYSTEM_NAME + '-' + Math.random().toString(16).substring(2);
|
|
36
36
|
this._ecOption = ecOption;
|
|
37
37
|
}
|
|
38
38
|
EChartsLayer.prototype.onAdd = function (map) {
|
|
39
39
|
this._map = map;
|
|
40
40
|
this._createLayerContainer();
|
|
41
|
+
if (!getCoordinateSystemDimensions(this._coordSystemName)) {
|
|
42
|
+
var coordinateSystem = new CoordinateSystem(this._coordSystemName, this._map);
|
|
43
|
+
registerCoordinateSystem(this._coordSystemName, coordinateSystem);
|
|
44
|
+
}
|
|
41
45
|
};
|
|
42
46
|
EChartsLayer.prototype.onRemove = function () {
|
|
43
47
|
var _a;
|
|
@@ -71,11 +75,6 @@ var EChartsLayer = /** @class */ (function () {
|
|
|
71
75
|
}
|
|
72
76
|
};
|
|
73
77
|
EChartsLayer.prototype._prepareECharts = function () {
|
|
74
|
-
if (!this._registered) {
|
|
75
|
-
var coordinateSystem = new CoordinateSystem(this._map);
|
|
76
|
-
registerCoordinateSystem(this._coordSystemName, coordinateSystem);
|
|
77
|
-
this._registered = true;
|
|
78
|
-
}
|
|
79
78
|
var series = this._ecOption.series;
|
|
80
79
|
if (series) {
|
|
81
80
|
for (var i = series.length - 1; i >= 0; i--) {
|
package/dist/js/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export default class EChartsLayer implements mapboxgl.CustomLayerInterface {
|
|
|
9
9
|
private _map;
|
|
10
10
|
private _ec;
|
|
11
11
|
private _coordSystemName;
|
|
12
|
-
private _registered;
|
|
13
12
|
private _ecOption;
|
|
14
13
|
constructor(id: string, ecOption: ECOption);
|
|
15
14
|
onAdd(map: mapboxgl.Map): void;
|
package/dist/js/index.js
CHANGED
|
@@ -3,43 +3,47 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var echarts_1 = require("echarts");
|
|
4
4
|
var COORDINATE_SYSTEM_NAME = 'mapboxgl-echarts';
|
|
5
5
|
var CoordinateSystem = /** @class */ (function () {
|
|
6
|
-
function CoordinateSystem(map) {
|
|
6
|
+
function CoordinateSystem(id, map) {
|
|
7
7
|
this.dimensions = ['x', 'y'];
|
|
8
8
|
this._mapOffset = [0, 0];
|
|
9
|
-
this.
|
|
9
|
+
this.id = id;
|
|
10
|
+
this._map = map;
|
|
10
11
|
}
|
|
11
12
|
CoordinateSystem.prototype.create = function (ecModel) {
|
|
12
13
|
var _this = this;
|
|
13
14
|
ecModel.eachSeries(function (seriesModel) {
|
|
14
|
-
if (seriesModel.get('coordinateSystem') ===
|
|
15
|
-
seriesModel.coordinateSystem = new CoordinateSystem(_this.
|
|
15
|
+
if (seriesModel.get('coordinateSystem') === _this.id) {
|
|
16
|
+
seriesModel.coordinateSystem = new CoordinateSystem(_this.id, _this._map);
|
|
16
17
|
}
|
|
17
18
|
});
|
|
18
19
|
};
|
|
19
20
|
CoordinateSystem.prototype.dataToPoint = function (data) {
|
|
20
|
-
var px = this.
|
|
21
|
+
var px = this._map.project(data);
|
|
21
22
|
var mapOffset = this._mapOffset;
|
|
22
23
|
return [px.x - mapOffset[0], px.y - mapOffset[1]];
|
|
23
24
|
};
|
|
24
25
|
CoordinateSystem.prototype.pointToData = function (pt) {
|
|
25
26
|
var mapOffset = this._mapOffset;
|
|
26
|
-
var data = this.
|
|
27
|
+
var data = this._map.unproject([pt[0] + mapOffset[0], pt[1] + mapOffset[1]]);
|
|
27
28
|
return [data.lng, data.lat];
|
|
28
29
|
};
|
|
29
30
|
return CoordinateSystem;
|
|
30
31
|
}());
|
|
31
32
|
var EChartsLayer = /** @class */ (function () {
|
|
32
33
|
function EChartsLayer(id, ecOption) {
|
|
33
|
-
this._registered = false;
|
|
34
34
|
this.id = id;
|
|
35
35
|
this.type = 'custom';
|
|
36
36
|
this.renderingMode = '2d';
|
|
37
|
-
this._coordSystemName = COORDINATE_SYSTEM_NAME;
|
|
37
|
+
this._coordSystemName = COORDINATE_SYSTEM_NAME + '-' + Math.random().toString(16).substring(2);
|
|
38
38
|
this._ecOption = ecOption;
|
|
39
39
|
}
|
|
40
40
|
EChartsLayer.prototype.onAdd = function (map) {
|
|
41
41
|
this._map = map;
|
|
42
42
|
this._createLayerContainer();
|
|
43
|
+
if (!(0, echarts_1.getCoordinateSystemDimensions)(this._coordSystemName)) {
|
|
44
|
+
var coordinateSystem = new CoordinateSystem(this._coordSystemName, this._map);
|
|
45
|
+
(0, echarts_1.registerCoordinateSystem)(this._coordSystemName, coordinateSystem);
|
|
46
|
+
}
|
|
43
47
|
};
|
|
44
48
|
EChartsLayer.prototype.onRemove = function () {
|
|
45
49
|
var _a;
|
|
@@ -73,11 +77,6 @@ var EChartsLayer = /** @class */ (function () {
|
|
|
73
77
|
}
|
|
74
78
|
};
|
|
75
79
|
EChartsLayer.prototype._prepareECharts = function () {
|
|
76
|
-
if (!this._registered) {
|
|
77
|
-
var coordinateSystem = new CoordinateSystem(this._map);
|
|
78
|
-
(0, echarts_1.registerCoordinateSystem)(this._coordSystemName, coordinateSystem);
|
|
79
|
-
this._registered = true;
|
|
80
|
-
}
|
|
81
80
|
var series = this._ecOption.series;
|
|
82
81
|
if (series) {
|
|
83
82
|
for (var i = series.length - 1; i >= 0; i--) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naivemap/mapbox-gl-echarts-layer",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Integrate the Lines graph and Scatter (bubble) chart of Apache ECharts.",
|
|
5
5
|
"author": "huanglii <li.huangli@qq.com>",
|
|
6
6
|
"homepage": "https://github.com/naivemap/mapbox-gl-layers#readme",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"echarts": "^5.3.2",
|
|
52
52
|
"npm-run-all": "^4.1.5"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "0c380c018a344ca66303d59269532fd7f8112074"
|
|
55
55
|
}
|