[OpenLayers-Users] how to query wms, like wfs?
zach cruise
zachc1980 at gmail.com
Sun Feb 23 13:24:13 PST 2014
to query wfs, i first specify layer, action and function:
var query = new OpenLayers.Control.SelectFeature(wfs_layer,
{ callbacks: { 'click': result }
});
then in the function, i style the attributes returned:
function result(feature) {
var html = "";
for (var i in feature.attributes) {
html += i + feature.attributes[i];
}
html += "";
OpenLayers.Util.getElement('div').innerHTML = html;
}
how do i do the same for wms
(http://mapserver.org/ogc/wms_server.html)? per
http://openlayers.org/dev/examples/getfeatureinfo-control.html, i
tried:
var query = {
click: new OpenLayers.Control.WMSGetFeatureInfo({
layers: [wms_layer]
})
};
for (var i in query) {
query[i].events.register("getfeatureinfo", this);
map.addControl(query[i]); // instead of map.addControl(query) for wfs
}
query.click.activate(); // instead of query.activate() for wfs
but where do i specify the function to style the attributes returned,
like before?
and clicking on a wms feature returns this:
<?xml version='1.0' encoding="ISO-8859-1" standalone="no" ?>
<!DOCTYPE ServiceExceptionReport SYSTEM
"http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd">
<ServiceExceptionReport version="1.1.1">
<ServiceException>
msWMSFeatureInfo(): WMS server error. Unsupported INFO_FORMAT value
(text/html).
</ServiceException>
</ServiceExceptionReport>
how do i fix INFO_FORMAT? (my map file =
MAP..WEB..METADATA.."wms_feature_info_mime_type"
"text/xml"..END..END..END).
working examples appreciated.
More information about the Users
mailing list