@@ -25,6 +25,7 @@ const minicharts_d3fns_geo = function() {
25
25
let width = 400 ;
26
26
let height = 100 ;
27
27
let map = null ;
28
+ let mousedown = false ;
28
29
let circleControl ;
29
30
let mapboxgl ;
30
31
@@ -214,6 +215,7 @@ const minicharts_d3fns_geo = function() {
214
215
}
215
216
216
217
map . dragPan . disable ( ) ;
218
+ mousedown = true ;
217
219
const p = d3 . mouse ( this ) ;
218
220
const ll = unproject ( [ p [ 0 ] , p [ 1 ] ] ) ;
219
221
@@ -236,6 +238,7 @@ const minicharts_d3fns_geo = function() {
236
238
} ) ;
237
239
238
240
container . on ( 'mouseup.circle' , function ( ) {
241
+ mousedown = false ;
239
242
if ( dragging && circleSelected ) return ;
240
243
241
244
map . dragPan . enable ( ) ;
@@ -296,15 +299,23 @@ const minicharts_d3fns_geo = function() {
296
299
297
300
298
301
function selectFromQuery ( ) {
302
+ // don't update from query while dragging the circle
303
+ if ( mousedown ) {
304
+ return ;
305
+ }
299
306
if ( options . query === undefined ) {
300
307
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 ) ;
308
319
}
309
320
}
310
321
// --- end chart setup ---
0 commit comments