Problem/Motivation

Problem Behavior

Using geoJSON Layer Type works fine if giving arbitrary GeoJSON Data on (/admin/structure/openlayers/layers/list/).

However, if using the URL option it is breaking the openlayers map. If it is set up to use URL (without any GeoJSON Data) and this layer is enabled then the map is not displayed at all.

Technical Explanation

This issue is caused by how the geoJSON data is being loaded when the BBOX option is disabled.
If the BBOX option is enabled it loads correctly because it is being loaded from another part of the code.

In addition, the logic used to choose the BBOX strategy could share some common code with other strategies as well.

Modules versions

openlayers 7.x-2.0-beta1+83-dev
views_geojson 7.x-1.0-alpha2

Proposed resolution

  • Change how the geoJSON URL is loaded, making it similar to the code used for BBOX strategy.
  • Share code between BBOX, Fixed , and other possible strategies. Only the strategy type must be changed, all the remaining loading code is the same.

edit: moved this issue to openlayers module as the patch is against one of its files.
edit[2]: added better issue description

Files: 
CommentFileSizeAuthor
#9 openlayers-fix_getting_geoJSON_layer_from_URL-1805844-9.patch2.32 KBMac_Weber
PASSED: [[SimpleTest]]: [MySQL] 238 pass(es).
[ View ]
#2 openlayers-fix_getting_geoJSON_layer_from_URL-1805844-2.patch2.32 KBMac_Weber
PASSED: [[SimpleTest]]: [MySQL] 238 pass(es).
[ View ]

Comments

Project:Views GeoJSON» OpenLayers
Version:7.x-1.0-alpha2» 7.x-3.x-dev

Moving to openlayers module.

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

Including patch to fix this issue.

BBOX filter is not working, see #1806048: BBOX filter not working

Status:Active» Needs review

Status:Needs review» Needs work

The last submitted patch, openlayers-fix_getting_geoJSON_layer_from_URL-1805844-2.patch, failed testing.

Status:Needs work» Needs review

Status:Needs review» Needs work

The last submitted patch, openlayers-fix_getting_geoJSON_layer_from_URL-1805844-2.patch, failed testing.

Version:7.x-3.x-dev» 7.x-2.x-dev
Status:Needs work» Needs review

Issue summary:View changes

edit: moved this issue to openlayers module as the patch is against one of its files.

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

Changed OpenLayers documentation links to version 2.12, as suggested by zzolo

Status:Needs review» Needs work

+++ b/plugins/layer_types/openlayers_layer_type_geojson.jsundefined
@@ -39,33 +39,28 @@ Drupal.openlayers.layer.geojson = function(title, map, options) {
-    var layer = new OpenLayers.Layer.Vector(title, options);
-
-    // Use an AJAX like call to get data from URL
-    OpenLayers.loadURL(options.url, {}, null, function (response) {
-      var format = new OpenLayers.Format.GeoJSON(geojson_options);
-      var features = format.read(response.responseText);
-      // Add features, if needed
-      if (features) {
-        layer.addFeatures(features);
-        layer.events.triggerEvent('loadend');
-      }
-    });

Are you sure about removing this part ?

Status:Needs work» Needs review

@pol yes, I am sure. Test it.

I removed it because it can use the same code on the lines before it, and that's how this new code is handling this part on this logic.

Status:Needs review» Fixed

Ok cool, committed then !

Thanks!

Pol, your commit is not removing the part you asked me on #10.
That part is never used in the new logic.

http://drupalcode.org/project/openlayers.git/blob/148267ea2e75ac1addcb5b...

Oops, looks like PHPStorm made a poo poo !

It's fixed again :)

http://drupalcode.org/project/openlayers.git/commitdiff/42bf5caacf03b729...

Status:Fixed» Closed (fixed)

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

Issue summary:View changes

Better issue description