diff --git a/views/views_geojson_bbox_argument.inc b/views/views_geojson_bbox_argument.inc
index 6e3c1f9..c4e0343 100644
--- a/views/views_geojson_bbox_argument.inc
+++ b/views/views_geojson_bbox_argument.inc
@@ -157,14 +157,14 @@ class views_geojson_bbox_argument extends views_handler_argument {
     if ($right - $left < 360) {
       $group = $this->query->set_where_group('AND');
       if ($left > -180) {
-        $this->query->add_where($group, "$lon_field_table.$lon_field_name", $left, '>=');
+        $this->filter($group, "$lon_field_table.$lon_field_name", $left, '>=');
       } else {
         $this->query->set_where_group('OR', $group);
         $left = -1 * ($left % 180);
-        $this->query->add_where($group, "$lon_field_table.$lon_field_name", array($left, 0), 'BETWEEN');
+        $this->filter($group, "$lon_field_table.$lon_field_name", array($left, 0), 'BETWEEN');
       }
       if ($right < 180) {
-        $this->query->add_where($group, "$lon_field_table.$lon_field_name", $right, '<=');
+        $this->filter($group, "$lon_field_table.$lon_field_name", $right, '<=');
       } else {
         $this->query->set_where_group('OR', $group);
         $right = -1 * ($right % 180);
@@ -175,7 +175,17 @@ class views_geojson_bbox_argument extends views_handler_argument {
     $bottom = $bbox['bottom'];
     $top = $bbox['top'];
     $group = $this->query->set_where_group('AND');
-    $this->query->add_where($group, "$lat_field_table.$lat_field_name", $bottom, '>=');
-    $this->query->add_where($group, "$lat_field_table.$lat_field_name", $top, '<=');
+    $this->filter($group, "$lat_field_table.$lat_field_name", $bottom, '>=');
+    $this->filter($group, "$lat_field_table.$lat_field_name", $top, '<=');
   }
-}
\ No newline at end of file
+
+  function filter($group, $field, $value = NULL, $operator = NULL) {
+    if (!$this->view->display_handler->use_group_by()) {
+      $this->query->add_where($group, $field, $value, $operator);
+    }
+    else {
+      $this->query->add_having($group, $field, $value, $operator);
+    }
+  }
+}
+
