@@ -41,16 +41,9 @@ class PlotLayer3D extends Observable {
4141 //是否在绘制图元,绘制途中不触发pick事件
4242 this . _isDrawing = false ;
4343
44- //常驻点击事件 ,针对vue组件做出的修改
44+ //标绘图元拾取事件 ,针对vue组件做出的修改
4545 this . _handler = new Cesium . ScreenSpaceEventHandler ( viewer . canvas ) ;
46- this . _handler . setInputAction ( ( event ) => {
47- if ( ! that . _isDrawing && that . _pickPlot ) {
48- const pick = viewer . scene . pick ( event . position ) ;
49- if ( pick && pick . primitive && pick . primitive . pickedPrimitive ) {
50- that . _pickPlot ( pick . primitive . pickedPrimitive )
51- }
52- }
53- } , this . _pickEventType ) ;
46+ this . _setPickPlot ( ) ;
5447
5548 this . _primitiveCollection . _id = this . _id ;
5649 let scene = this . _getScene ( ) ;
@@ -306,6 +299,22 @@ class PlotLayer3D extends Observable {
306299
307300 return lonlat ;
308301 } ;
302+
303+ /**
304+ * @description 标绘图元拾取事件,绘制中途不会触发该事件,只有绘制图元结束才会触发
305+ * @private
306+ */
307+ _setPickPlot ( ) {
308+ let that = this ;
309+ this . _handler . setInputAction ( ( event ) => {
310+ if ( ! that . _isDrawing && that . _pickPlot ) {
311+ const pick = viewer . scene . pick ( event . position ) ;
312+ if ( pick && pick . primitive && pick . primitive . pickedPrimitive ) {
313+ that . _pickPlot ( pick . primitive . pickedPrimitive )
314+ }
315+ }
316+ } , this . _pickEventType ) ;
317+ }
309318}
310319
311320Object . defineProperties ( PlotLayer3D . prototype , {
@@ -337,14 +346,7 @@ Object.defineProperties(PlotLayer3D.prototype, {
337346 let that = this ;
338347 this . _handler . removeInputAction ( this . _pickEventType ) ;
339348 this . _pickEventType = value ;
340- this . _handler . setInputAction ( ( event ) => {
341- if ( ! that . _isDrawing && that . _pickPlot ) {
342- const pick = viewer . scene . pick ( event . position ) ;
343- if ( pick && pick . primitive && pick . primitive . pickedPrimitive ) {
344- that . _pickPlot ( pick . primitive . pickedPrimitive )
345- }
346- }
347- } , this . _pickEventType ) ;
349+ this . _setPickPlot ( ) ;
348350 }
349351 }
350352} ) ;
0 commit comments