| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-05-09 13:19:53 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-12 00:21:25 | |||
| * @Last Modified time: 2020-05-12 09:27:35 | |||
| */ | |||
| import { DomUtil, Util } from './utils' | |||
| @@ -1,26 +0,0 @@ | |||
| /* | |||
| * @Author: Caven | |||
| * @Date: 2020-04-10 16:58:31 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-12 00:00:07 | |||
| */ | |||
| import { RoamingEventType } from './EventType' | |||
| import Event from './Event' | |||
| const { Cesium } = DC.Namespace | |||
| class RoamingEvent extends Event { | |||
| constructor() { | |||
| super() | |||
| } | |||
| _registerEvent() { | |||
| Object.keys(RoamingEventType).forEach(key => { | |||
| let type = RoamingEventType[key] | |||
| this._cache[type] = new Cesium.Event() | |||
| }) | |||
| } | |||
| } | |||
| export default RoamingEvent | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-13 10:13:53 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-11 22:37:07 | |||
| * @Last Modified time: 2020-05-12 09:27:31 | |||
| */ | |||
| import { Layer, VectorLayer } from './index' | |||
| @@ -2,11 +2,9 @@ | |||
| * @Author: Caven | |||
| * @Date: 2019-12-31 17:58:01 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-11 22:38:51 | |||
| * @Last Modified time: 2020-05-12 09:53:43 | |||
| */ | |||
| import Position from '../position/Position' | |||
| const CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split( | |||
| '' | |||
| ) | |||
| @@ -99,7 +97,12 @@ class Util { | |||
| * @param {*} position | |||
| */ | |||
| static checkPosition(position) { | |||
| return position && position instanceof Position | |||
| return ( | |||
| position && | |||
| position.hasOwnProperty('lng') && | |||
| position.hasOwnProperty('lat') && | |||
| position.hasOwnProperty('alt') | |||
| ) | |||
| } | |||
| /** | |||
| @@ -112,6 +115,15 @@ class Util { | |||
| positions && (typeof positions === 'string' || Array.isArray(positions)) | |||
| ) | |||
| } | |||
| /** | |||
| * @function checkViewer(viewer: Object): Boolean | |||
| * Check viewer for validity | |||
| * @param {*} position | |||
| */ | |||
| static checkViewer(viewer) { | |||
| return viewer && viewer.delegate && viewer.canvas | |||
| } | |||
| } | |||
| export default Util | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-31 15:51:32 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-11 23:08:29 | |||
| * @Last Modified time: 2020-05-12 10:00:09 | |||
| */ | |||
| import DrawPoint from './draw/DrawPoint' | |||
| @@ -13,12 +13,15 @@ import DrawRect from './draw/DrawRect' | |||
| import EditPoint from './edit/EditPoint' | |||
| import EditPolyline from './edit/EditPolyline' | |||
| const { VectorLayer, OverlayType } = DC | |||
| const { OverlayType, Util } = DC | |||
| const { Cesium } = DC.Namespace | |||
| class Plot { | |||
| constructor(viewer) { | |||
| if (!Util.checkViewer(viewer)) { | |||
| throw new Error('Plot: the viewer invalid') | |||
| } | |||
| this._viewer = viewer | |||
| this._plotEvent = new Cesium.Event() | |||
| this._callback = undefined | |||
| @@ -26,7 +29,7 @@ class Plot { | |||
| this._editWorker = undefined | |||
| this._drawLayer = new Cesium.CustomDataSource('plot-draw-layer') | |||
| this._viewer.delegate.dataSources.add(this._drawLayer) | |||
| this._markerLayer = new VectorLayer('plot-marker-layer') | |||
| this._markerLayer = new DC.VectorLayer('plot-marker-layer') | |||
| this._viewer.addLayer(this._markerLayer) | |||
| this._state = undefined | |||
| } | |||
| @@ -2,10 +2,10 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-31 19:45:32 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-10 10:57:23 | |||
| * @Last Modified time: 2020-05-12 09:39:12 | |||
| */ | |||
| const { Cesium } = DC.NameSpace | |||
| const { Cesium } = DC.Namespace | |||
| class Draw { | |||
| constructor(plotInfo) { | |||
| @@ -2,14 +2,14 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-01-31 19:44:41 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-11 22:31:32 | |||
| * @Last Modified time: 2020-05-12 09:34:37 | |||
| */ | |||
| import Draw from './Draw' | |||
| const { OverlayType, Transform } = DC | |||
| const { Cesium } = DC.NameSpace | |||
| const { Cesium } = DC.Namespace | |||
| const DEF_STYLE = { | |||
| width: 3, | |||
| @@ -9,7 +9,7 @@ import Draw from './Draw' | |||
| const { OverlayType, Transform } = DC | |||
| const { Cesium } = DC.NameSpace | |||
| const { Cesium } = DC.Namespace | |||
| const DEF_STYLE = { | |||
| pixelSize: 10, | |||
| @@ -9,7 +9,7 @@ import Draw from './Draw' | |||
| const { OverlayType, Transform } = DC | |||
| const { Cesium } = DC.NameSpace | |||
| const { Cesium } = DC.Namespace | |||
| const DEF_STYLE = { | |||
| material: Cesium.Color.BLUE.withAlpha(0.6) | |||
| @@ -9,7 +9,7 @@ import Draw from './Draw' | |||
| const { OverlayType, Transform } = DC | |||
| const { Cesium } = DC.NameSpace | |||
| const { Cesium } = DC.Namespace | |||
| const DEF_STYLE = { | |||
| width: 3, | |||
| @@ -9,7 +9,7 @@ import Draw from './Draw' | |||
| const { OverlayType, Transform } = DC | |||
| const { Cesium } = DC.NameSpace | |||
| const { Cesium } = DC.Namespace | |||
| const DEF_STYLE = { | |||
| material: Cesium.Color.BLUE.withAlpha(0.6) | |||
| @@ -7,7 +7,7 @@ | |||
| const { OverlayType, Transform } = DC | |||
| const { Cesium } = DC.NameSpace | |||
| const { Cesium } = DC.Namespace | |||
| class Edit { | |||
| constructor(plotInfo) { | |||
| @@ -2,7 +2,7 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-04-03 10:13:42 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-11 23:52:18 | |||
| * @Last Modified time: 2020-05-12 09:31:46 | |||
| */ | |||
| const install = function(DC) { | |||
| @@ -2,17 +2,17 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-03-02 23:14:20 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-11 22:17:25 | |||
| * @Last Modified time: 2020-05-12 09:56:16 | |||
| */ | |||
| const { Viewer, SceneEventType } = DC | |||
| const { SceneEventType, Util } = DC | |||
| const { Cesium } = DC.Namespace | |||
| class AroundView { | |||
| constructor(viewer, options = {}) { | |||
| if (!viewer || !(viewer instanceof Viewer)) { | |||
| throw new Error('the viewer invalid') | |||
| if (!Util.checkViewer(viewer)) { | |||
| throw new Error('AroundView: the viewer invalid') | |||
| } | |||
| this._viewer = viewer | |||
| this._options = options | |||
| @@ -2,21 +2,20 @@ | |||
| * @Author: Caven | |||
| * @Date: 2020-03-02 22:38:10 | |||
| * @Last Modified by: Caven | |||
| * @Last Modified time: 2020-05-11 21:39:33 | |||
| * @Last Modified time: 2020-05-12 09:57:49 | |||
| */ | |||
| const { Viewer, SceneEventType, Position, Transfrom } = DC | |||
| const { Util, SceneEventType, Transfrom } = DC | |||
| const { Cesium } = DC.Namespace | |||
| class AroundPoint { | |||
| constructor(viewer, position, options = {}) { | |||
| if ( | |||
| !position || | |||
| !(viewer instanceof Viewer) || | |||
| !(position instanceof Position) | |||
| ) { | |||
| throw new Error('the position invalid') | |||
| if (!Util.checkViewer(viewer)) { | |||
| throw new Error('AroundPoint:the viewer invalid') | |||
| } | |||
| if (!Util.checkPosition(position)) { | |||
| throw new Error('AroundPoint:the position invalid') | |||
| } | |||
| this._viewer = viewer | |||
| this._position = position | |||