Currently when enable the bounding box strategy and drag the map round it doesn't always send a request to the server for more information from your layer.

I have attached a patch that lets you change the resFactor see resFactor when you set this to 1 it will send an update everytime the resolution of the bounding box changes.

This is under the "Use Bounding Box Strategy" checkbox in the layers screen

this is against 7.x-2.x

diff --git a/plugins/layer_types/openlayers_layer_type_geojson.inc b/plugins/layer_types/openlayers_layer_type_geojson.inc
index 69d9530..23a8a5f 100644
--- a/plugins/layer_types/openlayers_layer_type_geojson.inc
+++ b/plugins/layer_types/openlayers_layer_type_geojson.inc
@@ -66,6 +66,25 @@ class openlayers_layer_type_geojson extends openlayers_layer_type {
         '#description' => t('Bounding Box strategy will add a query string onto the GeoJSON URL, which means that only data in the viewport of the map will be loaded.  This can be helpful if you have lots of data coming from the feed.'),
         '#default_value' => isset($this->data['useBBOX']) ? $this->data['useBBOX'] : FALSE,
       ),
+      //see http://dev.openlayers.org/docs/files/OpenLayers/Strategy/BBOX-js.html#OpenLayers.Strategy.BBOX.resFactor
+      'resFactor' => array(
+        '#type' => 'select',
+        '#title' => t('Used to determine when previously requested features are invalid (set to 1 if unsure)'),
+        '#description' => t('The resFactor will be compared to the resolution of the previous request to the current map resolution.  <br />
+          If resFactor > (old / new) and 1/resFactor < (old / new).
+          <ul>
+          <li>If you set a resFactor of 1, data will be requested every time the resolution changes.  </li>
+          <li>If you set a resFactor of 3, data will be requested if the old resolution is 3 times the new, or if the new is 3 times the old.  </li>
+          <li>If the old bounds do not contain the new bounds new data will always be requested (with or without considering resFactor).</li>
+          </ul>
+          '),
+        '#options' => array(
+            1 => t('1'),
+            2 => t('2'),
+            3 => t('3')
+        ),
+        '#default_value' => isset($this->data['resFactor']) ? $this->data['resFactor'] : 1
+      ),
       'geojson_data' => array(
         '#type' => 'textarea',
         '#title' => t('GeoJSON Data'),
diff --git a/plugins/layer_types/openlayers_layer_type_geojson.js b/plugins/layer_types/openlayers_layer_type_geojson.js
index f694d26..e4e6420 100644
--- a/plugins/layer_types/openlayers_layer_type_geojson.js
+++ b/plugins/layer_types/openlayers_layer_type_geojson.js
@@ -39,7 +39,7 @@ Drupal.openlayers.layer.geojson = function(title, map, options) {
     }
   }
   else if (options.useBBOX) {
-    options.strategies = [ new OpenLayers.Strategy.BBOX() ];
+    options.strategies = [new OpenLayers.Strategy.BBOX(options.resFactor)];
     options.protocol = new OpenLayers.Protocol.HTTP({
       url: options.url,
       format: new OpenLayers.Format.GeoJSON(),
Files: 
CommentFileSizeAuthor
#3 openlayers_bbox_resfactor-1555292-3.patch2.59 KBp4ul
PASSED: [[SimpleTest]]: [MySQL] 238 pass(es).
[ View ]
#1 openlayers_bbox_resfactor-1555292-1.patch2.49 KBp4ul
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/openlayers/plugins/layer_types/openlayers_layer_type_geojson.inc.
[ View ]

Comments

StatusFileSize
new2.49 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/openlayers/plugins/layer_types/openlayers_layer_type_geojson.inc.
[ View ]

As a patch

Status:Needs review» Needs work

The last submitted patch, openlayers_bbox_resfactor-1555292-1.patch, failed testing.

StatusFileSize
new2.59 KB
PASSED: [[SimpleTest]]: [MySQL] 238 pass(es).
[ View ]

fixed patch!

Status:Needs work» Needs review

Status:Needs review» Needs work

Patch is working but some formatting problems here...

+++ b/plugins/layer_types/openlayers_layer_type_geojson.incundefined
@@ -66,6 +66,25 @@ class openlayers_layer_type_geojson extends openlayers_layer_type {
+          If resFactor > (old / new) and 1/resFactor < (old / new). ¶

Remove useless spaces.

+++ b/plugins/layer_types/openlayers_layer_type_geojson.incundefined
@@ -66,6 +66,25 @@ class openlayers_layer_type_geojson extends openlayers_layer_type {
+          <ul>          ¶

Remove useless spaces.

+++ b/plugins/layer_types/openlayers_layer_type_geojson.incundefined
@@ -66,6 +66,25 @@ class openlayers_layer_type_geojson extends openlayers_layer_type {
+            1 => t('1'),
+            2 => t('2'),
+            3 => t('3')

Why t() here ?

Thanks for implementing this, p4ul!
Besides the code style issues Pol raised, a few things:

  1. resFactor can be any float -- 1 and 3 are just examples -- and is NULL by default.
  2. I would make resFactor the #title, or better yet, Bounding Box resFactor.
  3. We can probably chop the first couple sentences off the #description, or otherwise make it more succinct.

Thanks for the comments, t() was there so better explanations can be provided for each option the numbers where just a filler.
I will look at implementing those suggestions this week and resubmitting a patch.

Hi,

Can you guys give me some feedback on this please.

Original line:

'Bounding Box strategy will add a query string onto the GeoJSON URL, which means that only data in the viewport of the map will be loaded. This can be helpful if you have lots of data coming from the feed.'

proposed:

'The Bounding Box strategy will improve performance by only loading data on the visible area of the map.'

Good for me :)

@p4ul, I think that's a good improvement and we should go with it.
However, I was referring to the description for resFactor -- that's the long one...

Status:Needs work» Fixed

Committed, thanks !

Status:Fixed» Needs work

Please see my comments in #6, particularly:

resFactor can be any float -- 1 and 3 are just examples -- and is NULL by default.

Status:Needs work» Fixed

For reference, commits 3150369 and fdc4e58.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Issue summary:View changes

missed out default value when copying