Explorar el Código

imporve @dc-modules/plot

tags/2.2.5
Caven Chen hace 4 años
padre
commit
1a100f9fa4
Se han modificado 3 ficheros con 72 adiciones y 8 borrados
  1. 39
    4
      modules/plot/Plot.js
  2. 13
    2
      modules/plot/draw/Draw.js
  3. 20
    2
      modules/plot/edit/Edit.js

+ 39
- 4
modules/plot/Plot.js Ver fichero

@@ -101,6 +101,12 @@ class Plot {
this._plotEvent.addEventListener(this._completeCallback, this)
}

/**
*
* @param type
* @param style
* @private
*/
_createDrawWorker(type, style) {
switch (type) {
case OverlayType.POINT:
@@ -141,6 +147,11 @@ class Plot {
}
}

/**
*
* @param overlay
* @private
*/
_createEditWorker(overlay) {
switch (overlay.type) {
case OverlayType.POINT:
@@ -181,7 +192,15 @@ class Plot {
}
}

draw(type, callback, style) {
/**
*
* @param type
* @param callback
* @param style
* @param clampToGround
* @returns {Plot}
*/
draw(type, callback, style, clampToGround) {
this._state = 'draw'
if (this._drawWorker) {
this._drawWorker.unbindEvent()
@@ -190,10 +209,19 @@ class Plot {
this._viewer.tooltip.enable = true
this._bindEvent(callback)
this._createDrawWorker(type, style)
this._drawWorker && this._drawWorker.start(this)
this._drawWorker &&
this._drawWorker.start(this, clampToGround ?? this._options.clampToGround)
return this
}

edit(overlay, callback) {
/**
*
* @param overlay
* @param callback
* @param clampToGround
* @returns {Plot}
*/
edit(overlay, callback, clampToGround) {
this._state = 'edit'
if (this._editWorker) {
this._editWorker.unbindEvent()
@@ -202,15 +230,22 @@ class Plot {
this._viewer.tooltip.enable = true
this._bindEvent(callback)
this._createEditWorker(overlay)
this._editWorker && this._editWorker.start(this)
this._editWorker &&
this._editWorker.start(this, clampToGround ?? this._options.clampToGround)
return this
}

/**
*
* @returns {Plot}
*/
destroy() {
this._plotEvent.removeEventListener(this._completeCallback, this)
this._viewer.dataSources.remove(this._overlayLayer)
this._viewer.dataSources.remove(this._anchorLayer)
this._viewer = undefined
this._plotEvent = undefined
return this
}
}


+ 13
- 2
modules/plot/draw/Draw.js Ver fichero

@@ -51,6 +51,12 @@ class Draw {
this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this)
}

/**
*
* @param position
* @param isCenter
* @returns {*}
*/
createAnchor(position, isCenter = false) {
return this._layer.add({
position: position,
@@ -68,13 +74,18 @@ class Draw {
})
}

start(plot) {
/**
*
* @param plot
* @param clampToGround
*/
start(plot, clampToGround) {
this._viewer = plot.viewer
this._tooltip = plot.viewer.tooltip
this._layer = plot.overlayLayer
this._plotEvent = plot.plotEvent
this._options = plot.options
this._clampToGround = plot.options.clampToGround ?? true
this._clampToGround = clampToGround
this._mountEntity()
this.bindEvent()
}

+ 20
- 2
modules/plot/edit/Edit.js Ver fichero

@@ -63,6 +63,13 @@ class Edit {
this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this)
}

/**
*
* @param position
* @param index
* @param isMid
* @param isCenter
*/
createAnchor(position, index, isMid = false, isCenter = false) {
let image = isMid
? this._options.icon_midAnchor
@@ -92,6 +99,12 @@ class Edit {
this._anchors.push(anchor)
}

/**
*
* @param p1
* @param p2
* @returns {Cartesian3}
*/
computeMidPosition(p1, p2) {
let c1 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(p1)
let c2 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(p2)
@@ -99,14 +112,19 @@ class Edit {
return Cesium.Ellipsoid.WGS84.cartographicToCartesian(cm)
}

start(plot) {
/**
*
* @param plot
* @param clampToGround
*/
start(plot, clampToGround) {
this._viewer = plot.viewer
this._tooltip = plot.viewer.tooltip
this._layer = plot.overlayLayer
this._anchorLayer = plot.anchorLayer
this._plotEvent = plot.plotEvent
this._options = plot.options
this._clampToGround = plot.options.clampToGround ?? true
this._clampToGround = clampToGround
this._mountEntity()
this._mountAnchor()
this.bindEvent()

Cargando…
Cancelar
Guardar