-
-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
138 changed files
with
1,347 additions
and
1,080 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
@author : Caven Chen | ||
@date : 2023-05-23 | ||
*/ | ||
|
||
import { echarts } from '../../namespace' | ||
import { Layer } from '../layer' | ||
const { init } = echarts | ||
|
||
class ChartLayer extends Layer { | ||
constructor(id, viewer) { | ||
super(id) | ||
this._viewer.canvas.setAttribute('tabIndex', '0') | ||
this._chartEl = this._createChartElement() | ||
this._chart = init(this._chartEl) | ||
this._show = true | ||
Object(this._chart.getZr()).viewer = viewer | ||
} | ||
|
||
get id() { | ||
return this._id | ||
} | ||
|
||
set show(show) { | ||
this._show = show | ||
this._chartEl.style.visibility = show ? 'visible' : 'hidden' | ||
} | ||
|
||
get show() { | ||
return this._show | ||
} | ||
|
||
/** | ||
* | ||
* @returns {HTMLDivElement} | ||
* @private | ||
*/ | ||
_createChartElement() { | ||
let canvas = this._viewer.scene.canvas | ||
let el = document.createElement('div') | ||
el.setAttribute('id', this._id) | ||
el.style.cssText = `position:absolute; top:0; left:0; width: ${canvas.clientWidth}px; height: ${canvas.clientHeight}px;pointer-events:none;` | ||
this._viewer.container.appendChild(el) | ||
return el | ||
} | ||
|
||
/** | ||
* | ||
* @param option | ||
* @returns {ChartLayer} | ||
*/ | ||
setOption(option = {}) { | ||
this._chart.setOption({ ...option, GLMap: {}, animation: false }) | ||
return this | ||
} | ||
|
||
/** | ||
* | ||
* @returns {ChartLayer} | ||
*/ | ||
clear() { | ||
this._chart.clear() | ||
return this | ||
} | ||
|
||
/** | ||
* | ||
* @returns {ChartLayer} | ||
*/ | ||
resize() { | ||
this._chart.resize() | ||
return this | ||
} | ||
} | ||
|
||
export default ChartLayer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
@author : Caven Chen | ||
@date : 2023-05-23 | ||
*/ | ||
|
||
import { echarts, Cesium } from '../../namespace' | ||
const { Cartesian3, Ellipsoid, Math: CesiumMath } = Cesium | ||
const { graphic, matrix } = echarts | ||
|
||
class GLMapCoordSys { | ||
constructor(api) { | ||
this._api = api | ||
this._viewer = Object(api.getZr()).viewer | ||
this._mapOffset = [0, 0] | ||
this.dimensions = ['lng', 'lat'] | ||
} | ||
|
||
getViewer() { | ||
return this._viewer | ||
} | ||
|
||
setMapOffset(mapOffset) { | ||
this._mapOffset = mapOffset | ||
return this | ||
} | ||
|
||
dataToPoint(data) { | ||
let result = [] | ||
let cartesian3 = Cartesian3.fromDegrees(data[0], data[1]) | ||
if (!cartesian3) { | ||
return result | ||
} | ||
let up = Ellipsoid.WGS84.geodeticSurfaceNormal(cartesian3, new Cartesian3()) | ||
let cd = this._viewer.camera.direction | ||
if (Cartesian3.dot(up, cd) >= 0) { | ||
return result | ||
} | ||
let coords = this._viewer.scene.cartesianToCanvasCoordinates(cartesian3) | ||
if (!coords) { | ||
return result | ||
} | ||
return [coords.x - this._mapOffset[0], coords.y - this._mapOffset[1]] | ||
} | ||
|
||
pointToData(point) { | ||
let ellipsoid = this._viewer.scene.globe.ellipsoid | ||
let cartesian3 = new Cartesian3( | ||
point[0] + this._mapOffset[0], | ||
point[1] + this._mapOffset[1], | ||
0 | ||
) | ||
let cartographic = ellipsoid.cartesianToCartographic(cartesian3) | ||
return [ | ||
CesiumMath.toDegrees(cartographic.longitude), | ||
CesiumMath.toDegrees(cartographic.latitude), | ||
] | ||
} | ||
|
||
getViewRect() { | ||
let api = this._api | ||
return new graphic.BoundingRect(0, 0, api.getWidth(), api.getHeight()) | ||
} | ||
|
||
getRoamTransform() { | ||
return matrix.create() | ||
} | ||
|
||
static create(ecModel, api) { | ||
let coordinateSys = undefined | ||
ecModel.eachComponent('GLMap', function (model) { | ||
coordinateSys = new GLMapCoordSys(api) | ||
coordinateSys.setMapOffset(model['__mapOffset'] || [0, 0]) | ||
model.coordinateSystem = coordinateSys | ||
}) | ||
ecModel.eachSeries(function (model) { | ||
'GLMap' === model.get('coordinateSystem') && | ||
(model.coordinateSystem = coordinateSys) | ||
}) | ||
} | ||
} | ||
|
||
GLMapCoordSys.dimensions = ['lng', 'lat'] | ||
|
||
export default GLMapCoordSys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
@author : Caven Chen | ||
@date : 2023-05-23 | ||
*/ | ||
|
||
import { echarts } from '../../namespace' | ||
|
||
const { extendComponentModel } = echarts | ||
|
||
extendComponentModel({ | ||
type: 'GLMap', | ||
getViewer() { | ||
return Object(this.getZr()).viewer | ||
}, | ||
defaultOption: { | ||
roam: false, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
@Author: Caven Chen | ||
**/ | ||
|
||
import { echarts } from '../../namespace' | ||
|
||
const { extendComponentView } = echarts | ||
|
||
extendComponentView({ | ||
type: 'GLMap', | ||
init: function (ecModel, api) { | ||
this.api = api | ||
let viewer = api.getZr().viewer | ||
viewer.scene.postRender.addEventListener(this.moveHandler, this) | ||
}, | ||
moveHandler: function (t, e) { | ||
this.api.dispatchAction({ | ||
type: 'GLMapRoam', | ||
}) | ||
}, | ||
render: function (t, e, i) {}, | ||
dispose: function (t) { | ||
let viewer = this.api.getZr().viewer | ||
viewer.scene.postRender.removeEventListener(this.moveHandler, this) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
@Author: Caven Chen | ||
**/ | ||
|
||
import { echarts } from '../../namespace' | ||
|
||
import './GLMapModel' | ||
import './GLMapView' | ||
import GLMapCoordSys from './GLMapCoordSys' | ||
import ChartLayer from './ChartLayer.js' | ||
|
||
const { registerAction, registerCoordinateSystem } = echarts | ||
|
||
registerCoordinateSystem('GLMap', GLMapCoordSys) | ||
registerAction( | ||
{ | ||
type: 'GLMapRoam', | ||
event: 'GLMapRoam', | ||
update: 'updateLayout', | ||
}, | ||
function (payload, ecModel) {} | ||
) | ||
|
||
export { ChartLayer } |
Oops, something went wrong.