Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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(),
Comment | File | Size | Author |
---|---|---|---|
#3 | openlayers_bbox_resfactor-1555292-3.patch | 2.59 KB | p4ul |
#1 | openlayers_bbox_resfactor-1555292-1.patch | 2.49 KB | p4ul |
Comments
Comment #1
p4ul CreditAttribution: p4ul commentedAs a patch
Comment #3
p4ul CreditAttribution: p4ul commentedfixed patch!
Comment #4
p4ul CreditAttribution: p4ul commentedComment #5
PolPatch is working but some formatting problems here...
Remove useless spaces.
Remove useless spaces.
Why t() here ?
Comment #6
jeffschulerThanks for implementing this, p4ul!
Besides the code style issues Pol raised, a few things:
#title
, or better yet, Bounding Box resFactor.#description
, or otherwise make it more succinct.Comment #7
p4ul CreditAttribution: p4ul commentedThanks 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.
Comment #8
p4ul CreditAttribution: p4ul commentedHi,
Can you guys give me some feedback on this please.
Original line:
proposed:
Comment #9
PolGood for me :)
Comment #10
jeffschuler@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...
Comment #11
PolCommitted, thanks !
Comment #12
jeffschulerPlease see my comments in #6, particularly:
Comment #13
PolComment #14
jeffschulerFor reference, commits 3150369 and fdc4e58.
Comment #15.0
(not verified) CreditAttribution: commentedmissed out default value when copying