I'm having a map which is rendered through OpenLayers using GeoServer. The map contains various attribute data field like link_no, X_coord, Y_coord etc.
I want to highlight the link using link_no. I internally use WMS layer to render the map.
I got the following code from this wiki for highlighting purpose:
// define a blank Vector layer and add it to the map
var highlight_style = { fillColor:'#99CCFF', strokeColor:'#3399FF', fillOpacity:0.7 };
hilites = new OpenLayers.Layer.Vector("Highlighted",
{isBaseLayer:false, features:[], visibility:true, style:highlight_style}
);
map.addLayer(hilites);
// define the WFS server which will fill requests
var wfs_url = '/cgi-bin/mapserv?map=/maps/spraywatch2/wms/mapfile.map&SERVICE=WFS&VERSION=1.0.0';
/* highlightFeatures() makes the WFS request, then highlight_them() callback does the real work
* Args for WFS filter: typename, attribute, value
*/
function highlightFeatures(typename,attribute,value) {
var wfsurl = wfs_url + '&REQUEST=getfeature&typename=' + typename +
'&Filter=<Filter><PropertyIsEqualTo><PropertyName>'+attribute+'</PropertyName><Literal>'+value+'</Literal></PropertyIsEqualTo></Filter>';
OpenLayers.loadURL(wfsurl,'',null,highlight_them);
}
function highlight_them(response) {
// use the GML parser to turn the XML into a list of Feature objects
var features = new OpenLayers.Format.GML().read(response.responseText);
// have the Vector layer purge its feature list, replace them with the new ones
hilites.destroyFeatures();
hilites.addFeatures(features);
hilites.setVisibility(true);
}
Now what exactly is the typename, attribute and value parameters in the function highlightFeatures ? My aim is to highlight a particular link using a function call like this as explained in the wiki:
highlightFeatures('parcels','parcel_id','123456')
The above function call was an example given in the wiki link.