@naivemap/echarts-layer-core 0.1.0 → 0.2.0-alpha.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.
@@ -1,7 +1,7 @@
1
1
  import { ComposeOption, EffectScatterSeriesOption, LegendComponentOption, LinesSeriesOption, ScatterSeriesOption, TitleComponentOption, TooltipComponentOption } from 'echarts';
2
- import { LayerController, LayerMap } from '../../map-gl-layer-adaptor/src/index.ts';
2
+ import { LayerController, LayerMap } from '@naivemap/map-gl-layer-adaptor';
3
3
  /**
4
- * the options for the EChartsLayer. It is the same as the options of ECharts, but only supports a subset of them. For more details, please refer to the ECharts documentation.
4
+ * The options for the EChartsLayer. It is the same as the options of ECharts, but only supports a subset of them. For more details, please refer to the ECharts documentation.
5
5
  * @see https://echarts.apache.org/en/option.html
6
6
  */
7
7
  export type ECOption = ComposeOption<TitleComponentOption | TooltipComponentOption | LegendComponentOption | LinesSeriesOption | ScatterSeriesOption | EffectScatterSeriesOption>;
@@ -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.EChartsLayerCore=s(i.echarts))})(this,function(i){"use strict";const s="gl-layer-echarts";class a{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 a(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 r{_container;_map;_ec;_coordSystemName;_ecOption;constructor(t){this._coordSystemName=s+"-"+Math.random().toString(16).substring(2),this._ecOption=t}onAdd(t){if(this._map=t,this._createLayerContainer(),!i.getCoordinateSystemDimensions(this._coordSystemName)){const e=new a(this._coordSystemName,this._map);i.registerCoordinateSystem(this._coordSystemName,e)}}onRemove(){this._ec?.dispose(),this._removeLayerContainer()}setOption(t,e){this._ecOption=t,this._ec?.setOption(t,e)}render(){if(this._container||this._createLayerContainer(),!this._ec){this._ec=i.init(this._container),this._prepareECharts(),this._ec.setOption(this._ecOption);return}if(this._map.isMoving()){this._ec.clear();return}this._ec.resize({width:this._map.getCanvas().width,height:this._map.getCanvas().height}),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 r});
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@naivemap/echarts-layer-core",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-alpha.1",
4
4
  "description": "Map engine agnostic ECharts custom layer core.",
5
- "main": "./dist/index.cjs",
6
- "module": "./dist/index.js",
5
+ "main": "./dist/index.umd.js",
6
+ "module": "./dist/index.es.js",
7
7
  "type": "module",
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js",
12
- "require": "./dist/index.cjs"
11
+ "import": "./dist/index.es.js",
12
+ "require": "./dist/index.umd.js"
13
13
  }
14
14
  },
15
15
  "files": [
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "sideEffects": false,
32
32
  "dependencies": {
33
- "@naivemap/map-gl-layer-adaptor": "0.1.0"
33
+ "@naivemap/map-gl-layer-adaptor": "0.2.0-alpha.1"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "echarts": "^5.0.0"
package/dist/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";const s=require("echarts"),n="gl-layer-echarts";class a{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 a(this.id,this._map))})}dataToPoint(t){const e=this._map.project(t),i=this._mapOffset;return[e.x-i[0],e.y-i[1]]}pointToData(t){const e=this._mapOffset,i=this._map.unproject([t[0]+e[0],t[1]+e[1]]);return[i.lng,i.lat]}}class r{_container;_map;_ec;_coordSystemName;_ecOption;constructor(t){this._coordSystemName=n+"-"+Math.random().toString(16).substring(2),this._ecOption=t}onAdd(t){if(this._map=t,this._createLayerContainer(),!s.getCoordinateSystemDimensions(this._coordSystemName)){const e=new a(this._coordSystemName,this._map);s.registerCoordinateSystem(this._coordSystemName,e)}}onRemove(){this._ec?.dispose(),this._removeLayerContainer()}setOption(t,e){this._ecOption=t,this._ec?.setOption(t,e)}render(){if(this._container||this._createLayerContainer(),!this._ec){this._ec=s.init(this._container),this._prepareECharts(),this._ec.setOption(this._ecOption);return}if(this._map.isMoving()){this._ec.clear();return}this._ec.resize({width:this._map.getCanvas().width,height:this._map.getCanvas().height}),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)}}module.exports=r;
File without changes