@naivemap/mapbox-gl-echarts-layer 0.1.2 → 0.1.4

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,17 +1,17 @@
1
- # mapbox-gl-echarts-layer
2
-
3
- [全国主要城市空气质量 - 百度地图](https://huanglii.github.io/mapbox-gl-js-cookbook/example/echarts-scatter.html)
4
-
5
- ```bash
6
- npm i @naivemap/mapbox-gl-echarts-layer
7
- ```
8
-
9
- ```js
10
- import EchartsLayer from '@naivemap/mapbox-gl-echarts-layer'
11
-
12
- // echart option
13
- const option = {...}
14
- const layer = new EchartsLayer('layer-id', option)
15
-
16
- map.addLayer(layer)
17
- ```
1
+ # mapbox-gl-echarts-layer
2
+
3
+ [全国主要城市空气质量 - 百度地图](https://huanglii.github.io/mapbox-gl-js-cookbook/example/echarts-scatter.html)
4
+
5
+ ```bash
6
+ npm i @naivemap/mapbox-gl-echarts-layer
7
+ ```
8
+
9
+ ```js
10
+ import EchartsLayer from '@naivemap/mapbox-gl-echarts-layer'
11
+
12
+ // echart option
13
+ const option = {...}
14
+ const layer = new EchartsLayer('layer-id', option)
15
+
16
+ map.addLayer(layer)
17
+ ```
@@ -25,13 +25,13 @@ class CoordinateSystem {
25
25
  }
26
26
  }
27
27
  class EchartsLayer {
28
- constructor(id, ecOptions) {
28
+ constructor(id, ecOption) {
29
29
  this._registered = false;
30
30
  this.id = id;
31
31
  this.type = "custom";
32
32
  this.renderingMode = "2d";
33
33
  this._coordSystemName = COORDINATE_SYSTEM_NAME;
34
- this._ecOptions = ecOptions;
34
+ this._ecOption = ecOption;
35
35
  }
36
36
  onAdd(map) {
37
37
  this._map = map;
@@ -53,7 +53,7 @@ class EchartsLayer {
53
53
  if (!this._ec) {
54
54
  this._ec = echarts.init(this._container);
55
55
  this._prepareECharts();
56
- this._ec.setOption(this._ecOptions);
56
+ this._ec.setOption(this._ecOption);
57
57
  } else {
58
58
  if (this._map.isMoving()) {
59
59
  this._ec.clear();
@@ -62,7 +62,7 @@ class EchartsLayer {
62
62
  width: this._map.getCanvas().width,
63
63
  height: this._map.getCanvas().height
64
64
  });
65
- this._ec.setOption(this._ecOptions);
65
+ this._ec.setOption(this._ecOption);
66
66
  }
67
67
  }
68
68
  }
@@ -72,7 +72,7 @@ class EchartsLayer {
72
72
  echarts.registerCoordinateSystem(this._coordSystemName, coordinateSystem);
73
73
  this._registered = true;
74
74
  }
75
- const series = this._ecOptions.series;
75
+ const series = this._ecOption.series;
76
76
  if (series) {
77
77
  for (let i = series.length - 1; i >= 0; i--) {
78
78
  series[i]["coordinateSystem"] = this._coordSystemName;
@@ -1 +1 @@
1
- (function(n,r){typeof exports=="object"&&typeof module!="undefined"?module.exports=r(require("echarts")):typeof define=="function"&&define.amd?define(["echarts"],r):(n=typeof globalThis!="undefined"?globalThis:n||self,n.EchartsLayer=r(n.echarts))})(this,function(n){"use strict";function r(i){if(i&&i.__esModule)return i;var e={__proto__:null,[Symbol.toStringTag]:"Module"};return i&&Object.keys(i).forEach(function(t){if(t!=="default"){var s=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:function(){return i[t]}})}}),e.default=i,Object.freeze(e)}var o=r(n);const h="mapboxgl-echarts";class a{constructor(e){this.dimensions=["x","y"],this._mapOffset=[0,0],this.map=e}create(e){e.eachSeries(t=>{t.get("coordinateSystem")===h&&(t.coordinateSystem=new a(this.map))})}dataToPoint(e){const t=this.map.project(e),s=this._mapOffset;return[t.x-s[0],t.y-s[1]]}pointToData(e){const t=this._mapOffset,s=this.map.unproject([e[0]+t[0],e[1]+t[1]]);return[s.lng,s.lat]}}class c{constructor(e,t){this._registered=!1,this.id=e,this.type="custom",this.renderingMode="2d",this._coordSystemName=h,this._ecOptions=t}onAdd(e){this._map=e,this._createLayerContainer()}onRemove(){this._ec.dispose(),this._removeLayerContainer()}setOption(e){this._ec&&this._ec.setOption(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._ecOptions)):(this._ec=o.init(this._container),this._prepareECharts(),this._ec.setOption(this._ecOptions))}_prepareECharts(){if(!this._registered){const t=new a(this._map);o.registerCoordinateSystem(this._coordSystemName,t),this._registered=!0}const e=this._ecOptions.series;if(e)for(let t=e.length-1;t>=0;t--)e[t].coordinateSystem=this._coordSystemName}_createLayerContainer(){const e=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,e.appendChild(this._container)}_removeLayerContainer(){var e;this._container&&((e=this._container.parentNode)==null||e.removeChild(this._container))}}return c});
1
+ (function(n,r){typeof exports=="object"&&typeof module!="undefined"?module.exports=r(require("echarts")):typeof define=="function"&&define.amd?define(["echarts"],r):(n=typeof globalThis!="undefined"?globalThis:n||self,n.EchartsLayer=r(n.echarts))})(this,function(n){"use strict";function r(i){if(i&&i.__esModule)return i;var e={__proto__:null,[Symbol.toStringTag]:"Module"};return i&&Object.keys(i).forEach(function(t){if(t!=="default"){var s=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:function(){return i[t]}})}}),e.default=i,Object.freeze(e)}var o=r(n);const h="mapboxgl-echarts";class a{constructor(e){this.dimensions=["x","y"],this._mapOffset=[0,0],this.map=e}create(e){e.eachSeries(t=>{t.get("coordinateSystem")===h&&(t.coordinateSystem=new a(this.map))})}dataToPoint(e){const t=this.map.project(e),s=this._mapOffset;return[t.x-s[0],t.y-s[1]]}pointToData(e){const t=this._mapOffset,s=this.map.unproject([e[0]+t[0],e[1]+t[1]]);return[s.lng,s.lat]}}class c{constructor(e,t){this._registered=!1,this.id=e,this.type="custom",this.renderingMode="2d",this._coordSystemName=h,this._ecOption=t}onAdd(e){this._map=e,this._createLayerContainer()}onRemove(){this._ec.dispose(),this._removeLayerContainer()}setOption(e){this._ec&&this._ec.setOption(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=o.init(this._container),this._prepareECharts(),this._ec.setOption(this._ecOption))}_prepareECharts(){if(!this._registered){const t=new a(this._map);o.registerCoordinateSystem(this._coordSystemName,t),this._registered=!0}const e=this._ecOption.series;if(e)for(let t=e.length-1;t>=0;t--)e[t].coordinateSystem=this._coordSystemName}_createLayerContainer(){const e=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,e.appendChild(this._container)}_removeLayerContainer(){var e;this._container&&((e=this._container.parentNode)==null||e.removeChild(this._container))}}return c});
package/package.json CHANGED
@@ -1,41 +1,46 @@
1
- {
2
- "name": "@naivemap/mapbox-gl-echarts-layer",
3
- "version": "0.1.2",
4
- "description": "mapbox-gl-echarts-layer",
5
- "files": [
6
- "dist"
7
- ],
8
- "types": "./dist/mapbox-gl-echarts-layer.d.ts",
9
- "main": "./dist/mapbox-gl-echarts-layer.umd.js",
10
- "module": "./dist/mapbox-gl-echarts-layer.es.js",
11
- "exports": {
12
- ".": {
13
- "import": "./dist/mapbox-gl-echarts-layer.es.js",
14
- "require": "./dist/mapbox-gl-echarts-layer.umd.js"
15
- }
16
- },
17
- "scripts": {
18
- "dev": "vite",
19
- "lint": "eslint src --fix --ext .ts,.tsx,.vue,.js,.jsx",
20
- "prettier": "prettier --write .",
21
- "build": "vite build"
22
- },
23
- "repository": "https://github.com/naivemap/mapbox-gl-echarts-layer",
24
- "keywords": ["mapbox-gl", "echarts"],
25
- "license": "MIT",
26
- "dependencies": {
27
- "echarts": "^5.3.0"
28
- },
29
- "devDependencies": {
30
- "@types/mapbox-gl": "^2.6.1",
31
- "@types/node": "^17.0.15",
32
- "@typescript-eslint/eslint-plugin": "^5.10.2",
33
- "@typescript-eslint/parser": "^5.10.2",
34
- "eslint": "^8.8.0",
35
- "eslint-config-prettier": "^8.3.0",
36
- "eslint-plugin-prettier": "^4.0.0",
37
- "prettier": "^2.5.1",
38
- "typescript": "^4.5.5",
39
- "vite": "^2.7.13"
40
- }
41
- }
1
+ {
2
+ "name": "@naivemap/mapbox-gl-echarts-layer",
3
+ "version": "0.1.4",
4
+ "description": "mapbox-gl-echarts-layer",
5
+ "files": [
6
+ "dist",
7
+ "types"
8
+ ],
9
+ "types": "./types/index.d.ts",
10
+ "main": "./dist/mapbox-gl-echarts-layer.umd.js",
11
+ "module": "./dist/mapbox-gl-echarts-layer.es.js",
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/mapbox-gl-echarts-layer.es.js",
15
+ "require": "./dist/mapbox-gl-echarts-layer.umd.js"
16
+ }
17
+ },
18
+ "scripts": {
19
+ "dev": "vite",
20
+ "lint": "eslint src --fix --ext .ts,.tsx,.vue,.js,.jsx",
21
+ "prettier": "prettier --write .",
22
+ "build": "vite build"
23
+ },
24
+ "repository": "https://github.com/naivemap/mapbox-gl-echarts-layer",
25
+ "keywords": [
26
+ "mapbox-gl",
27
+ "echarts"
28
+ ],
29
+ "license": "MIT",
30
+ "peerDependencies": {
31
+ "echarts": "^5.3.0"
32
+ },
33
+ "devDependencies": {
34
+ "@types/mapbox-gl": "^2.6.1",
35
+ "@types/node": "^17.0.15",
36
+ "@typescript-eslint/eslint-plugin": "^5.10.2",
37
+ "@typescript-eslint/parser": "^5.10.2",
38
+ "echarts": "^5.3.0",
39
+ "eslint": "^8.8.0",
40
+ "eslint-config-prettier": "^8.3.0",
41
+ "eslint-plugin-prettier": "^4.0.0",
42
+ "prettier": "^2.5.1",
43
+ "typescript": "^4.5.5",
44
+ "vite": "^2.7.13"
45
+ }
46
+ }
@@ -0,0 +1,37 @@
1
+ /// <reference types="mapbox-gl" />
2
+ import * as echarts from 'echarts'
3
+ import {
4
+ EffectScatterSeriesOption,
5
+ LegendComponentOption,
6
+ LinesSeriesOption,
7
+ ScatterSeriesOption,
8
+ TitleComponentOption,
9
+ TooltipComponentOption,
10
+ } from 'echarts'
11
+ export declare type ECOption = echarts.ComposeOption<
12
+ | TitleComponentOption
13
+ | TooltipComponentOption
14
+ | LegendComponentOption
15
+ | LinesSeriesOption
16
+ | ScatterSeriesOption
17
+ | EffectScatterSeriesOption
18
+ >
19
+ export default class EchartsLayer implements mapboxgl.CustomLayerInterface {
20
+ id: string
21
+ type: 'custom'
22
+ renderingMode: '2d'
23
+ private _container
24
+ private _map
25
+ private _ec
26
+ private _coordSystemName
27
+ private _registered
28
+ private _ecOption
29
+ constructor(id: string, ecOption: ECOption)
30
+ onAdd(map: mapboxgl.Map): void
31
+ onRemove(): void
32
+ setOption(option: ECOption): void
33
+ render(): void
34
+ private _prepareECharts
35
+ private _createLayerContainer
36
+ private _removeLayerContainer
37
+ }