Hi,

I guess everyone is busy at FOSS4G and I understand that. Since I'm unable to log on the trac system, here's a patch to fix the following issue :

With current trunk version, when using OpenLayers.Format.GeoJSON with a geojson string containing "FeatureCollection", in IE it can't load any features. See a live example showing the issue [1]. The json string contains 1 feature. In Firefox, when alerting obj.features.length we get "1" but in IE we get "2", thus resulting in an error and "null" is returned instead of the features.

The attached patch resolves the issue. but it's more kinda of a "plaster" instead of a "remedy" (it's still bleeding, but we don't see it). Any better solution would be welcomed. See the same example as before with the fix [2].

Please, let me know when the trac issue is fixed and I'll open a ticket for this bug.

[1] http://dev4.mapgears.com/tests/openlayers-testsgeojson/examples/vector-features.html [2] http://dev4.mapgears.com/tests/openlayers-testsgeojson-withfix/examples/vector-features.html

--
Alexandre Dubé
Mapgears
www.mapgears.com

Index: lib/OpenLayers/Format/GeoJSON.js
===================================================================
--- lib/OpenLayers/Format/GeoJSON.js	(revision 10720)
+++ lib/OpenLayers/Format/GeoJSON.js	(working copy)
@@ -114,6 +114,9 @@
                             break;
                         case "FeatureCollection":
                             for(var i=0, len=obj.features.length; i<len; ++i) {
+                                if (!obj.features[i]) {
+                                    continue;
+                                }
                                 try {
                                     results.push(this.parseFeature(obj.features[i]));
                                 } catch(err) {
_______________________________________________
Dev mailing list
d...@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-dev

Reply via email to