summaryrefslogtreecommitdiff
path: root/misc/openlayers/examples/wfs-spatial-filter.js
diff options
context:
space:
mode:
Diffstat (limited to 'misc/openlayers/examples/wfs-spatial-filter.js')
-rw-r--r--misc/openlayers/examples/wfs-spatial-filter.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/misc/openlayers/examples/wfs-spatial-filter.js b/misc/openlayers/examples/wfs-spatial-filter.js
new file mode 100644
index 0000000..4ca9fd5
--- /dev/null
+++ b/misc/openlayers/examples/wfs-spatial-filter.js
@@ -0,0 +1,36 @@
+OpenLayers.ProxyHost= "proxy.cgi?url=";
+var map = new OpenLayers.Map('map');
+var wms = new OpenLayers.Layer.WMS(
+ "OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0",
+ {layers: "basic"}
+);
+
+var layer = new OpenLayers.Layer.Vector("WFS", {
+ strategies: [new OpenLayers.Strategy.BBOX()],
+ protocol: new OpenLayers.Protocol.WFS({
+ url: "http://demo.opengeo.org/geoserver/wfs",
+ featureType: "tasmania_roads",
+ featureNS: "http://www.openplans.org/topp"
+ })
+});
+
+map.addLayers([wms, layer]);
+map.setCenter(new OpenLayers.LonLat(146.7, -41.8), 6);
+
+var drawings = new OpenLayers.Layer.Vector();
+map.addLayer(drawings);
+var draw = new OpenLayers.Control.DrawFeature(drawings, OpenLayers.Handler.Polygon);
+map.addControl(draw);
+draw.activate();
+
+drawings.events.on({
+ beforefeatureadded: function(event) {
+ var geometry = event.feature.geometry;
+ layer.filter = new OpenLayers.Filter.Spatial({
+ type: OpenLayers.Filter.Spatial.INTERSECTS,
+ value: event.feature.geometry
+ });
+ layer.refresh({force: true});
+ return false;
+ }
+});