Skip to content

Commit 0330b25

Browse files
rueckstiessThomas Rueckstiess
authored andcommitted
COMPASS-444 fix geo query building behavior. (#634)
1 parent 0665747 commit 0330b25

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/internal-packages/schema/lib/d3/coordinates.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const minicharts_d3fns_geo = function() {
2525
let width = 400;
2626
let height = 100;
2727
let map = null;
28+
let mousedown = false;
2829
let circleControl;
2930
let mapboxgl;
3031

@@ -214,6 +215,7 @@ const minicharts_d3fns_geo = function() {
214215
}
215216

216217
map.dragPan.disable();
218+
mousedown = true;
217219
const p = d3.mouse(this);
218220
const ll = unproject([p[0], p[1]]);
219221

@@ -236,6 +238,7 @@ const minicharts_d3fns_geo = function() {
236238
});
237239

238240
container.on('mouseup.circle', function() {
241+
mousedown = false;
239242
if (dragging && circleSelected) return;
240243

241244
map.dragPan.enable();
@@ -296,15 +299,23 @@ const minicharts_d3fns_geo = function() {
296299

297300

298301
function selectFromQuery() {
302+
// don't update from query while dragging the circle
303+
if (mousedown) {
304+
return;
305+
}
299306
if (options.query === undefined) {
300307
circleControl.clear(true);
301-
} else {
302-
const center = options.query.$geoWithin.$centerSphere[0];
303-
const radius = options.query.$geoWithin.$centerSphere[1] * 3963.2;
304-
// only redraw if the center/radius is different to the existing circle
305-
if (radius !== mileDistance || !_.isEqual(center, [circleCenter.lng, circleCenter.lat])) {
306-
circleControl.setCircle(center, radius);
307-
}
308+
return;
309+
}
310+
const center = _.get(options.query, '$geoWithin.$centerSphere[0]');
311+
const radius = _.get(options.query, '$geoWithin.$centerSphere[1]', 0) * 3963.2;
312+
if (!center || !radius) {
313+
circleControl.clear(true);
314+
return;
315+
}
316+
// only redraw if the center/radius is different to the existing circle
317+
if (radius !== mileDistance || !_.isEqual(center, [circleCenter.lng, circleCenter.lat])) {
318+
circleControl.setCircle(center, radius);
308319
}
309320
}
310321
// --- end chart setup ---

0 commit comments

Comments
 (0)