How I can add logical operators AND
, OR
both together for WFS in OpenLayers.
<script type="text/javascript">
var map;
function init() {
var bounds = new OpenLayers.Bounds(
2309872.5, 2399960.25,
2388258.25, 2450114.75
);
var options = {
controls: [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoom()
],
maxExtent: bounds,
maxResolution: 306.1943359375,
projection: "EPSG:32644",
units: 'm'
};
map = new OpenLayers.Map('map', options);
var map_wms = new OpenLayers.Layer.WMS(
"cite:union - Tiled", "http://localhost:8080/geoserver/cite/wms",
{
LAYERS: 'cite:union',
tiled: true,
EPSG:32644,
tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
},
{
buffer: 0,
displayOutsideMaxExtent: true,
isBaseLayer: true
}
);
var layerPolygon2 = new OpenLayers.Layer.Vector("Layer Information", {
strategies: [new OpenLayers.Strategy.BBOX()],
visibility: true,
protocol: new OpenLayers.Protocol.WFS({
version: "1.0.0",
srsName: "EPSG:32644", // this is the default
url: "http://localhost:8080/geoserver/cite/wfs",
featureType:"union",
featureNS: "http://www.opengeospatial.net/cite",
extractAttributes: true,
transparent:true,
geometryName: "the_geom"
})
filter: new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.AND,
filters: [
new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.OR,
filters: [
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "classes",
value: "A?Pt"
}),
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "classes",
value: "P"
})
]
)}
new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.OR,
filters: [
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "luse_2005",
value: "BU"
}),
new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "luse_2005",
value: "CL"
})
]
)}
]
})
});
map.addLayers([map_wms,layerPolygon2]);
map.zoomToMaxExtent();
}
</script>
</head>
<body onLoad="init()">
<div id="map" style="border:1px solid black;width:900px; height:700px;"></div>
</body>
</html>
When I try to run above code in browser nothing is being displayed and Firebug is showing an ReferenceError: init is not defined init() error
.
Best Answer
BradHards...I have just define a rule outside the vector layer and use this in vector as we do to give style for vector layers.