From 05887ecf50270de47a3681017dd711e53d76c1c2 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Mon, 2 Mar 2009 02:06:01 +0000 Subject: [PATCH] fix for WFS Layer getDataExtent always pulls from markers subclass, r=tschaub (Closes #1725) git-svn-id: http://svn.openlayers.org/trunk/openlayers@8929 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/WFS.js | 19 +++++++++++++++++++ tests/Layer/WFS.html | 10 ++++++++++ 2 files changed, 29 insertions(+) diff --git a/lib/OpenLayers/Layer/WFS.js b/lib/OpenLayers/Layer/WFS.js index f0ea8fedd3..96eb9e4423 100644 --- a/lib/OpenLayers/Layer/WFS.js +++ b/lib/OpenLayers/Layer/WFS.js @@ -531,6 +531,25 @@ OpenLayers.Layer.WFS = OpenLayers.Class( this.tile.draw(); } }, + + /** + * APIMethod: getDataExtent + * Calculates the max extent which includes all of the layer data. + * + * Returns: + * {} + */ + getDataExtent: function () { + var extent; + //get all additions from superclasses + if (this.vectorMode) { + extent = OpenLayers.Layer.Vector.prototype.getDataExtent.apply(this); + } else { + extent = OpenLayers.Layer.Markers.prototype.getDataExtent.apply(this); + } + + return extent; + }, CLASS_NAME: "OpenLayers.Layer.WFS" }); diff --git a/tests/Layer/WFS.html b/tests/Layer/WFS.html index 09f55461f3..6c0d295215 100644 --- a/tests/Layer/WFS.html +++ b/tests/Layer/WFS.html @@ -15,6 +15,16 @@ } + function test_Layer_WFS_getDataExtent(t) { + t.plan(1); + + var layer = new OpenLayers.Layer.WFS(name, "url", {}); + layer.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0, 0))); + layer.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0, 1))); + t.eq(layer.getDataExtent().toBBOX(), "0,0,0,1", "bbox is correctly pulled from vectors."); + + } + function test_Layer_WFS_destroy(t) { t.plan(13);