| Project: | OpenLayers |
| Version: | 7.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
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
Comments
#1
Moving to openlayers module.
#2
Including patch to fix this issue.
BBOX filter is not working, see #1806048: BBOX filter not working
#3
#4
The last submitted patch, openlayers-fix_getting_geoJSON_layer_from_URL-1805844-2.patch, failed testing.
#5
#2: openlayers-fix_getting_geoJSON_layer_from_URL-1805844-2.patch queued for re-testing.
#6
The last submitted patch, openlayers-fix_getting_geoJSON_layer_from_URL-1805844-2.patch, failed testing.
#7
#8
#2: openlayers-fix_getting_geoJSON_layer_from_URL-1805844-2.patch queued for re-testing.
#9
Changed OpenLayers documentation links to version 2.12, as suggested by zzolo
#10
+++ 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 ?
#11
@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.
#12
Ok cool, committed then !
Thanks!
#13
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...
#14
Oops, looks like PHPStorm made a poo poo !
It's fixed again :)
http://drupalcode.org/project/openlayers.git/commitdiff/42bf5caacf03b729...
#15
Automatically closed -- issue fixed for 2 weeks with no activity.