Add support for reprojection of vector formats when loading data. This allows

for the definition of a 'projection' option on a layer. IF this projection 
object exists, it will be used to create the format's internal/external 
projection options, making it such that any data loaded will be reprojected 
to the map's projection automatically. r=pagameba (Closes #1273, #1225, #1269) 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@5828 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2008-01-20 20:33:54 +00:00
parent 7a19fd6a95
commit f28a1c314a
7 changed files with 159 additions and 21 deletions
+17 -2
View File
@@ -28,6 +28,13 @@ OpenLayers.Layer.GML = OpenLayers.Class(OpenLayers.Layer.Vector, {
* {<OpenLayers.Format>} The format you want the data to be parsed with.
*/
format: null,
/**
* APIProperty: formatOptions
* {Object} Hash of options which should be passed to the format when it is
* created. Must be passed in the constructor.
*/
formatOptions: null,
/**
* Constructor: OpenLayers.Layer.GML
@@ -127,8 +134,16 @@ OpenLayers.Layer.GML = OpenLayers.Class(OpenLayers.Layer.Vector, {
if (!doc || request.fileType!="XML") {
doc = request.responseText;
}
var gml = this.format ? new this.format() : new OpenLayers.Format.GML();
var options = {};
OpenLayers.Util.extend(options, this.formatOptions);
if (this.map && !this.projection.equals(this.map.getProjectionObject())) {
options.externalProjection = this.projection;
options.internalProjection = this.map.getProjectionObject();
}
var gml = this.format ? new this.format(options) : new OpenLayers.Format.GML(options);
this.addFeatures(gml.read(doc));
this.events.triggerEvent("loadend");
},