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:
@@ -29,6 +29,13 @@ OpenLayers.Layer.GeoRSS = OpenLayers.Class(OpenLayers.Layer.Markers, {
|
||||
* Array({<OpenLayers.Feature>})
|
||||
*/
|
||||
features: 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,
|
||||
|
||||
/**
|
||||
* Property: selectedFeature
|
||||
@@ -69,8 +76,6 @@ OpenLayers.Layer.GeoRSS = OpenLayers.Class(OpenLayers.Layer.Markers, {
|
||||
OpenLayers.Layer.Markers.prototype.initialize.apply(this, [name, options]);
|
||||
this.location = location;
|
||||
this.features = [];
|
||||
this.events.triggerEvent("loadstart");
|
||||
OpenLayers.loadURL(location, null, this, this.parseData);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -86,6 +91,36 @@ OpenLayers.Layer.GeoRSS = OpenLayers.Class(OpenLayers.Layer.Markers, {
|
||||
this.clearFeatures();
|
||||
this.features = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: loadRSS
|
||||
* Start the load of the RSS data. Don't do this when we first add the layer,
|
||||
* since we may not be visible at any point, and it would therefore be a waste.
|
||||
*/
|
||||
loadRSS: function() {
|
||||
if (!this.loaded) {
|
||||
this.events.triggerEvent("loadstart");
|
||||
OpenLayers.loadURL(this.location, null, this, this.parseData);
|
||||
this.loaded = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: moveTo
|
||||
* If layer is visible and RSS has not been loaded, load RSS.
|
||||
*
|
||||
* Parameters:
|
||||
* bounds - {Object}
|
||||
* zoomChanged - {Object}
|
||||
* minor - {Object}
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, minor) {
|
||||
OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments);
|
||||
if(this.visibility && !this.loaded){
|
||||
this.events.triggerEvent("loadstart");
|
||||
this.loadRSS();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: parseData
|
||||
@@ -113,7 +148,16 @@ OpenLayers.Layer.GeoRSS = OpenLayers.Class(OpenLayers.Layer.Markers, {
|
||||
}
|
||||
}
|
||||
|
||||
var format = new OpenLayers.Format.GeoRSS();
|
||||
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 format = new OpenLayers.Format.GeoRSS(options);
|
||||
var features = format.read(doc);
|
||||
|
||||
for (var i = 0; i < features.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user