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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mac_Weber’s picture

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

Moving to openlayers module.

Mac_Weber’s picture

Including patch to fix this issue.

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

Mac_Weber’s picture

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.

Mac_Weber’s picture

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.

Mac_Weber’s picture

Version: 7.x-3.x-dev » 7.x-2.x-dev
Status: Needs work » Needs review
Mac_Weber’s picture

Mac_Weber’s picture

Issue summary: View changes

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

Mac_Weber’s picture

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

Pol’s picture

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 ?

Mac_Weber’s picture

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.

Pol’s picture

Status: Needs review » Fixed

Ok cool, committed then !

Thanks!

Mac_Weber’s picture

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...

Pol’s picture

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.

Anonymous’s picture

Issue summary: View changes

Better issue description