1 /* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
2 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
3 * text of the license. */
4 // @require: OpenLayers/Tile.js
8 OpenLayers.Tile.WFS = Class.create();
9 OpenLayers.Tile.WFS.prototype =
10 Object.extend( new OpenLayers.Tile(), {
12 /** @type Array(OpenLayers.Feature)*/
19 * @param {OpenLayers.Layer} layer
20 * @param {OpenLayers.Pixel} position
21 * @param {OpenLayers.Bounds} bounds
23 * @param {OpenLayers.Size} size
25 initialize: function(layer, position, bounds, url, size) {
26 OpenLayers.Tile.prototype.initialize.apply(this, arguments);
28 this.features = new Array();
35 for(var i=0; i < this.features.length; i++) {
36 this.features[i].destroy();
38 OpenLayers.Tile.prototype.destroy.apply(this, arguments);
44 this.loadFeaturesForRegion(this.requestSuccess);
48 /** get the full request string from the ds and the tile params
49 * and call the AJAX loadURL().
51 * input are function pointers for what to do on success and failure.
53 * @param {function} success
54 * @param {function} failure
56 loadFeaturesForRegion:function(success, failure) {
62 // TODO: Hmmm, this stops multiple loads of the data when a
63 // result isn't immediately retrieved, but it's hacky.
66 OpenLayers.loadURL(this.url, null, this, success, failure);
71 /** Return from AJAX request
75 requestSuccess:function(request) {
76 var doc = request.responseXML;
78 if (!doc || request.fileType!="XML") {
79 doc = OpenLayers.parseXMLString(request.responseText);
82 var resultFeatures = doc.getElementsByTagName("featureMember");
84 //clear old featureList
85 this.features = new Array();
87 for (var i=0; i < resultFeatures.length; i++) {
89 var feature = new this.layer.featureClass(this.layer,
91 this.features.append(feature);
96 /** @final @type String */
97 CLASS_NAME: "OpenLayers.Tile.WFS"