make spatial filter configurable for OpenLayers.Control.GetFeature, p=rdewit, r=me (closes #2325)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@9770 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
bartvde
2009-11-02 07:12:53 +00:00
parent cf4c14a1e4
commit d9fd39d547
2 changed files with 21 additions and 5 deletions

View File

@@ -14,7 +14,7 @@
* Class: OpenLayers.Control.GetFeature
* Gets vector features for locations underneath the mouse cursor. Can be
* configured to act on click, hover or dragged boxes. Uses an
* <OpenLayers.Protocol> that supports spatial filters (BBOX) to retrieve
* <OpenLayers.Protocol> that supports spatial filters to retrieve
* features from a server and fires events that notify applications of the
* selected features.
*
@@ -80,10 +80,10 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
/**
* APIProperty: clickTolerance
* {Integer} Tolerance for the BBOX query in pixels. This has the
* {Integer} Tolerance for the filter query in pixels. This has the
* same effect as the tolerance parameter on WMS GetFeatureInfo
* requests. Will be ignored for box selections. Applies only if
* <click> of <hover> is true. Default is 5. Note that this not
* <click> or <hover> is true. Default is 5. Note that this not
* only affects requests on click, but also on hover.
*/
clickTolerance: 5,
@@ -142,6 +142,15 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
*/
hoverResponse: null,
/**
* Property: filterType
* {<String>} The type of filter to use when sending off a request.
* Possible values:
* OpenLayers.Filter.Spatial.<BBOX|INTERSECTS|WITHIN|CONTAINS>
* Defaults to: OpenLayers.Filter.Spatial.BBOX
*/
filterType: OpenLayers.Filter.Spatial.BBOX,
/**
* Constant: EVENT_TYPES
*
@@ -332,7 +341,7 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
request: function(bounds, options) {
options = options || {};
var filter = new OpenLayers.Filter.Spatial({
type: OpenLayers.Filter.Spatial.BBOX,
type: this.filterType,
value: bounds
});

View File

@@ -3,7 +3,7 @@
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_Control_GetFeature_constructor(t) {
t.plan(2);
t.plan(3);
var protocol = "foo";
var control = new OpenLayers.Control.GetFeature({
protocol: protocol
@@ -12,6 +12,13 @@
"new OpenLayers.Control.SelectFeature returns an instance");
t.eq(control.protocol, "foo",
"constructor sets protocol correctly");
control = new OpenLayers.Control.GetFeature({
filterType: OpenLayers.Filter.Spatial.INTERSECTS
});
t.eq(control.filterType, OpenLayers.Filter.Spatial.INTERSECTS,
"constructor sets filterType correctly");
}
function test_Control_GetFeature_select(t) {