From 4d221db5a7e3d3b34caa807fc0d49f20df64873a Mon Sep 17 00:00:00 2001 From: yiyuezhuo Date: Mon, 15 Feb 2021 15:00:22 +0800 Subject: [PATCH 1/2] try to enable click anywhere in Geo mode --- src/components/fx/click.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/fx/click.js b/src/components/fx/click.js index a4f17e44674..0da63cc3628 100644 --- a/src/components/fx/click.js +++ b/src/components/fx/click.js @@ -21,7 +21,11 @@ module.exports = function click(gd, evt, subplot) { if(evt && evt.target) { if(gd._hoverdata) { data = gd._hoverdata; - } else if(clickmode.indexOf('anywhere') > -1) { + } else if(gd._fullLayout.geo){ + var lat = gd._fullLayout.geo._subplot.xaxis.p2c(); + var lon = gd._fullLayout.geo._subplot.yaxis.p2c(); + data = [{lat: lat, lon: lon}]; + }else if(clickmode.indexOf('anywhere') > -1) { var xaxis = gd._fullLayout.xaxis; var yaxis = gd._fullLayout.yaxis; var bb = evt.target.getBoundingClientRect(); From 461b695bf9f3c490118ecf602db23891f88e4447 Mon Sep 17 00:00:00 2001 From: yiyuezhuo Date: Tue, 16 Feb 2021 19:17:37 +0800 Subject: [PATCH 2/2] fix anywhere leak problem --- src/components/fx/click.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/components/fx/click.js b/src/components/fx/click.js index 0da63cc3628..14c1c3f4000 100644 --- a/src/components/fx/click.js +++ b/src/components/fx/click.js @@ -21,17 +21,20 @@ module.exports = function click(gd, evt, subplot) { if(evt && evt.target) { if(gd._hoverdata) { data = gd._hoverdata; - } else if(gd._fullLayout.geo){ - var lat = gd._fullLayout.geo._subplot.xaxis.p2c(); - var lon = gd._fullLayout.geo._subplot.yaxis.p2c(); - data = [{lat: lat, lon: lon}]; }else if(clickmode.indexOf('anywhere') > -1) { - var xaxis = gd._fullLayout.xaxis; - var yaxis = gd._fullLayout.yaxis; - var bb = evt.target.getBoundingClientRect(); - var x = xaxis.p2d(evt.clientX - bb.left); - var y = yaxis.p2d(evt.clientY - bb.top); - data = [{x: x, y: y}]; + if(gd._fullLayout.geo){ + var lat = gd._fullLayout.geo._subplot.xaxis.p2c(); + var lon = gd._fullLayout.geo._subplot.yaxis.p2c(); + data = [{lat: lat, lon: lon}]; + } + else{ + var xaxis = gd._fullLayout.xaxis; + var yaxis = gd._fullLayout.yaxis; + var bb = evt.target.getBoundingClientRect(); + var x = xaxis.p2d(evt.clientX - bb.left); + var y = yaxis.p2d(evt.clientY - bb.top); + data = [{x: x, y: y}]; + } } if(data) { if(annotationsDone && annotationsDone.then) {