Skip to content

Commit f44196f

Browse files
authored
fix:Defend against the issue of being unable to obtain coordinates wh… (#2451)
* fix:Defend against the issue of being unable to obtain coordinates when the mouse moves to the sky. * fix:Defend against the issue of being unable to obtain coordinates when the mouse moves to the sky
1 parent adba026 commit f44196f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/map/tool/DrawTool.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ class DrawTool extends MapTool {
455455
*/
456456
//@internal
457457
_mouseDownHandler(event: any) {
458+
if(!event?.coordinate) {
459+
return
460+
}
458461
this._createGeometry(event);
459462
}
460463

@@ -468,6 +471,9 @@ class DrawTool extends MapTool {
468471
*/
469472
//@internal
470473
_mouseUpHandler(event: any) {
474+
if(!event?.coordinate) {
475+
return
476+
}
471477
this.endDraw(event);
472478
}
473479

@@ -481,6 +487,9 @@ class DrawTool extends MapTool {
481487
*/
482488
//@internal
483489
_clickHandler(event: any) {
490+
if(!event?.coordinate) {
491+
return
492+
}
484493
if (!this.options.interactive) {
485494
return this;
486495
}
@@ -559,6 +568,7 @@ class DrawTool extends MapTool {
559568
*/
560569
//@internal
561570
_createGeometry(event: any) {
571+
562572
const mode = this.getMode();
563573
const map: any = this.getMap()
564574
const registerMode = this._getRegisterMode();
@@ -634,6 +644,9 @@ class DrawTool extends MapTool {
634644
*/
635645
//@internal
636646
_mouseMoveHandler(event) {
647+
if(!event?.coordinate) {
648+
return
649+
}
637650
if (!this.options.interactive) {
638651
return this;
639652
}
@@ -704,6 +717,9 @@ class DrawTool extends MapTool {
704717
*/
705718
//@internal
706719
_doubleClickHandler(event) {
720+
if(!event?.coordinate) {
721+
return
722+
}
707723
if (!this.options.interactive) {
708724
return this;
709725
}

0 commit comments

Comments
 (0)