diff --git a/lib/OpenLayers/Format/GeoJSON.js b/lib/OpenLayers/Format/GeoJSON.js index d70b9fa2c4..5a0bd39575 100644 --- a/lib/OpenLayers/Format/GeoJSON.js +++ b/lib/OpenLayers/Format/GeoJSON.js @@ -212,7 +212,7 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, { if (obj == null) { return null; } - var geometry; + var geometry, collection = false; if(obj.type == "GeometryCollection") { if(!(obj.geometries instanceof Array)) { throw "GeometryCollection must have geometries array: " + obj; @@ -225,6 +225,7 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, { ); } geometry = new OpenLayers.Geometry.Collection(components); + collection = true; } else { if(!(obj.coordinates instanceof Array)) { throw "Geometry must have coordinates array: " + obj; @@ -241,7 +242,9 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, { throw err; } } - if (this.internalProjection && this.externalProjection) { + // We don't reproject collections because the children are reprojected + // for us when they are created. + if (this.internalProjection && this.externalProjection && !collection) { geometry.transform(this.externalProjection, this.internalProjection); } diff --git a/tests/manual/geojson-geomcoll-reprojection.html b/tests/manual/geojson-geomcoll-reprojection.html new file mode 100644 index 0000000000..e82e08a330 --- /dev/null +++ b/tests/manual/geojson-geomcoll-reprojection.html @@ -0,0 +1,74 @@ + + + + + + + + + +
+ +