I have a vector layer in openlayers with source in GEOJSON (custom php server, which I have in complete control) and BBOX strategy.
Vector points contain point sources which have different attributes. I want to implement some filters by one or two attributes. I can manage server side php code – for e.g. I can get the filters by adding URL parameters to existing url like:
Existing URL: mywebservice.php
Filtered URL: mywebservice.php?someattributte=somevalue
How do I implement it on the OpenLayers side?
My code is as follows:
var in_options = {
'internalProjection': EPSG_900913,
'externalProjection': EPSG_4326
};
var ems_sources = new OpenLayers.Layer.Vector(EMS_SOURCES_TITLE, {
strategies: [
new OpenLayers.Strategy.BBOX({
resFactor: 2,
active: true,
autoActivate: true,
ratio: 1.3
})
],
protocol: new OpenLayers.Protocol.HTTP({
url: EMS_SOURCES_WS,
callbackKey: 'callback',
format: new OpenLayers.Format.GeoJSON(in_options)
})
});
Best Answer
You can pass params object in the
OpenLayers.Protocol.HTTP
. See here http://dev.openlayers.org/docs/files/OpenLayers/Protocol/HTTP-js.html#OpenLayers.Protocol.HTTP.paramsyour protocol part of code should look like