blob: 4ca9fd56245e897bdd8f1f10bd3b130d3edc070b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;
}
});
|