Browse Source

improve the plot #39

tags/2.3.1
Caven Chen 4 years ago
parent
commit
095a2f870a
3 changed files with 16 additions and 25 deletions
  1. 1
    0
      modules/event/EventType.js
  2. 1
    1
      modules/math/index.js
  3. 14
    24
      modules/tools/EditTool.js

+ 1
- 0
modules/event/EventType.js View File

EDIT_STOP: 'editEnd', EDIT_STOP: 'editEnd',
DRAW_ANCHOR: 'drawAnchor', DRAW_ANCHOR: 'drawAnchor',
CREATE_ANCHOR: 'createAnchor', CREATE_ANCHOR: 'createAnchor',
UPDATE_ANCHOR: 'updateAnchor',
ANCHOR_MOVING: 'anchorMoving', ANCHOR_MOVING: 'anchorMoving',
EDIT_ANCHOR_STOP: 'editAnchorStop', EDIT_ANCHOR_STOP: 'editAnchorStop',
CLEAR_ANCHOR: 'clearAnchor' CLEAR_ANCHOR: 'clearAnchor'

+ 1
- 1
modules/math/index.js View File

*/ */


export { default as area } from './area' export { default as area } from './area'
export { default as center } from './center'
export { default as bounds } from './bounds' export { default as bounds } from './bounds'
export { default as mid } from './mid' export { default as mid } from './mid'
export { default as center } from './center'
export { default as distance } from './distance' export { default as distance } from './distance'
export { default as heading } from './heading' export { default as heading } from './heading'
export { default as isBetween } from './isBetween' export { default as isBetween } from './isBetween'

+ 14
- 24
modules/tools/EditTool.js View File

this._pickedAnchor.position && this._pickedAnchor.position &&
this._pickedAnchor.properties this._pickedAnchor.properties
) { ) {
let properties = this._pickedAnchor.properties.getValue(
Cesium.JulianDate.now()
)
this._pickedAnchor.position.setValue(position) this._pickedAnchor.position.setValue(position)
this._plotEvent.fire(PlotEventType.EDIT_ANCHOR_STOP, { this._plotEvent.fire(PlotEventType.EDIT_ANCHOR_STOP, {
index: properties.index,
pickedAnchor: this._pickedAnchor,
position: position position: position
}) })
} }
this._pickedAnchor.position && this._pickedAnchor.position &&
this._pickedAnchor.properties this._pickedAnchor.properties
) { ) {
let properties = this._pickedAnchor.properties.getValue(
Cesium.JulianDate.now()
)
this._pickedAnchor.position.setValue(position) this._pickedAnchor.position.setValue(position)
this._plotEvent.fire(PlotEventType.ANCHOR_MOVING, { this._plotEvent.fire(PlotEventType.ANCHOR_MOVING, {
index: properties.index,
pickedAnchor: this._pickedAnchor,
position: position position: position
}) })
} }
* @private * @private
*/ */
_onRightClick(e) { _onRightClick(e) {
this._plotEvent.fire(
PlotEventType.DRAW_STOP,
let position =
this._options.clampToModel && e.position ? e.position : e.surfacePosition this._options.clampToModel && e.position ? e.position : e.surfacePosition
)
this._plotEvent.fire(PlotEventType.DRAW_STOP, {
pickedAnchor: this._pickedAnchor,
position: position
})
} }


/** /**
this._anchors.push(anchor) this._anchors.push(anchor)
} }


_onUpdateAnchor({ index, position }) {
this._anchors[index] && this._anchors[index].position.setValue(position)
}

/** /**
* *
* @private * @private
*/ */
_onClearAnchor() { _onClearAnchor() {
this._anchorLayer.entities.removeAll() this._anchorLayer.entities.removeAll()
this._anchors = []
} }


/** /**
this._viewer.on(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) this._viewer.on(MouseEventType.MOUSE_MOVE, this._onMouseMove, this)
this._viewer.on(MouseEventType.RIGHT_CLICK, this._onRightClick, this) this._viewer.on(MouseEventType.RIGHT_CLICK, this._onRightClick, this)
this.on(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this) this.on(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this.on(PlotEventType.UPDATE_ANCHOR, this._onUpdateAnchor, this)
this.on(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) this.on(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
} }


this._viewer.off(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) this._viewer.off(MouseEventType.MOUSE_MOVE, this._onMouseMove, this)
this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this) this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this)
this.off(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this) this.off(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this.off(PlotEventType.UPDATE_ANCHOR, this._onUpdateAnchor, this)
this.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) this.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
} }


/**
*
* @param p1
* @param p2
* @returns {Cartesian3}
*/
computeMidPosition(p1, p2) {
let c1 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(p1)
let c2 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(p2)
let cm = new Cesium.EllipsoidGeodesic(c1, c2).interpolateUsingFraction(0.5)
return Cesium.Ellipsoid.WGS84.cartographicToCartesian(cm)
}

/** /**
* *
* @param type * @param type

Loading…
Cancel
Save