@@ -21,9 +21,11 @@ export default class MeasureToolLayer extends BaseTextLayer<TextData> {
2121 rulerOn : boolean ;
2222 dragging : boolean ;
2323 yValue : number ;
24+ hovering : boolean ;
2425
2526 moveHandler : ( e : GeoEvent ) => void ;
2627 mousedownHandler : ( e : GeoEvent ) => void ;
28+ hoverHandler : ( e : GeoEvent ) => void ;
2729 mouseupHandler : ( ) => void ;
2830
2931 constructor (
@@ -58,6 +60,7 @@ export default class MeasureToolLayer extends BaseTextLayer<TextData> {
5860 this . dragging = false ;
5961 this . yValue = 0 ;
6062 this . color = 'white' ;
63+ this . hovering = false ;
6164
6265 this . textStyle = this . createTextStyle ( ) ;
6366 this . rulerOn = measuring || false ;
@@ -68,27 +71,41 @@ export default class MeasureToolLayer extends BaseTextLayer<TextData> {
6871 this . moveHandler = ( e : GeoEvent ) => {
6972 if ( e && this . dragging ) {
7073 this . updateRuler ( e . mouse . geo . y ) ;
74+ }
75+ } ;
76+ this . hoverHandler = ( e : GeoEvent ) => {
77+ if ( e ) {
78+ const gcs = this . geoViewerRef . displayToGcs ( e . map ) ;
79+ const p = this . pointAnnotation . data ( ) [ 0 ] ;
80+ const dx = Math . abs ( gcs . x - p . x ) ;
81+ const dy = Math . abs ( gcs . y - p . y ) ;
82+ if ( Math . sqrt ( dx * dx + dy * dy ) < 20 || dy < 10 ) {
83+ this . event ( 'update:cursor' , { cursor : 'grab' } ) ;
84+ this . hovering = true ;
85+ return ;
86+ } else {
87+ this . event ( 'update:cursor' , { cursor : 'default' } ) ;
88+ }
7189 }
90+ this . hovering = false ;
7291 } ;
7392 this . mousedownHandler = ( e : GeoEvent ) => {
74- const gcs = this . geoViewerRef . displayToGcs ( e . map ) ;
75- const p = this . pointAnnotation . data ( ) [ 0 ] ;
76- const dx = Math . abs ( gcs . x - p . x ) ;
77- const dy = Math . abs ( gcs . y - p . y ) ;
78- if ( Math . sqrt ( dx * dx + dy * dy ) < 20 || dy < 10 ) {
93+ if ( this . hovering && e . buttons . left ) {
7994 this . geoViewerRef . interactor ( ) . addAction ( {
8095 action : 'dragpoint' ,
8196 name : 'drag point with mouse' ,
8297 owner : 'MeasureToolLayer' ,
8398 input : 'left' ,
8499 } ) ;
85100 this . dragging = true ;
101+ this . event ( 'update:cursor' , { cursor : 'grabbing' } ) ;
86102 }
87103 } ;
88104 this . mouseupHandler = ( ) => {
89105 this . dragging = false ;
90106 this . geoViewerRef . interactor ( ) . removeAction ( undefined , undefined , 'MeasureToolLayer' ) ;
91107 this . updateRuler ( this . yValue ) ;
108+ this . event ( 'update:cursor' , { cursor : 'grab' } ) ;
92109 } ;
93110 }
94111
@@ -107,6 +124,7 @@ export default class MeasureToolLayer extends BaseTextLayer<TextData> {
107124 this . geoViewerRef . geoOn ( geo . event . mousedown , this . mousedownHandler ) ;
108125 this . geoViewerRef . geoOn ( geo . event . actionmove , this . moveHandler ) ;
109126 this . geoViewerRef . geoOn ( geo . event . mouseup , this . mouseupHandler ) ;
127+ this . geoViewerRef . geoOn ( geo . event . mousemove , this . hoverHandler ) ;
110128 this . frequencyRulerLayer . draw ( ) ;
111129 this . updateRuler ( this . yValue ) ;
112130 }
@@ -164,6 +182,7 @@ export default class MeasureToolLayer extends BaseTextLayer<TextData> {
164182 this . geoViewerRef . geoOff ( geo . event . mousedown , this . mousedownHandler ) ;
165183 this . geoViewerRef . geoOff ( geo . event . mouseup , this . mouseupHandler ) ;
166184 this . geoViewerRef . geoOff ( geo . event . actionmove , this . moveHandler ) ;
185+ this . geoViewerRef . geoOff ( geo . event . mousemove , this . hoverHandler ) ;
167186 }
168187
169188 clearRulerLayer ( ) {
0 commit comments