I'm trying to use the getfeatureinfo
function of Openlayers with MapServer
. When I click on a point on my map, I get the following error in Firebug:
<?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 code="LayerNotQueryable">
msWMSFeatureInfo(): WMS server error. Requested layer(s) are not queryable.
</ServiceException>
</ServiceExceptionReport>
I've included the javascript and mapfile that I am using. As far as I can tell, I have the correct arguments in my Mapfile but it does not appear to enable querying using getfeatureinfo
. I'm also a little unclear on how my html templates should be structured or if they are essential for this.
This is the javascript (I am using OpenLayers 2.12):
info = new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://mysite.com/mapserv.cgi?MAP=points.map',
title: 'Identify features by clicking',
queryVisible: true,
eventListeners: {
getfeatureinfo: function(event) {
console.log(event.text)
}
}
});
map.addControl(info);
info.activate();
And this is my mapfile, points.map
:
MAP
IMAGETYPE PNG
EXTENT -9780000 2770000 -8850000 3650000
SIZE 500 600
SHAPEPATH "/home/data"
IMAGECOLOR 255 255 255
PROJECTION
"init=epsg:900913"
END
CONFIG "MS_ERRORFILE" "/home/tmp/ms_error.txt"
DEBUG 5
WEB
METADATA
"wms_title" "WMS Demo Server"
"wms_onlineresource" "http://mysite.com/mapserv.cgi?MAP=points.map&"
"wms_srs" "EPSG:900913"
"wms_enable_request" "*"
"ows_enable_request" "*"
END
END
##### symbol definition
SYMBOL
NAME "circle"
TYPE ellipse
FILLED true
POINTS
1 1
END
END
####### layer
LAYER
NAME points
CONNECTIONTYPE POSTGIS
CONNECTION "host=localhost dbname=data user=postgres port=5432"
DATA "geom from points using unique gid using SRID=3086"
HEADER 'head.html'
FOOTER 'foot.html'
METADATA
"wms_enable_request" "*"
"gml_include_items" "all"
"wms_include_items" "all"
END
STATUS ON
TYPE POINT
PROJECTION
"init=epsg:3086"
END
CLASS
NAME 'point symbols'
STYLE
SYMBOL "circle"
COLOR 100 100 100
OUTLINECOLOR 10 10 10
SIZE 50
END
END
END
END
My template files are very basic – just <html><body>
for the HEADER
and </body></html>
for the FOOTER
.
Where am I going wrong in this overall process?
Best Answer
If I have understood your question, you have created the HEADER and the FOOTER files, but not the TEMPLATE one. The latter file is mandatory, and in your scenario it 'generates' the contents of HTML's body.
Besides, inside the LAYER object of your mapfile there should also be a reference to the template file, given via TEMPLATE.
For point based queries, it is advisable you also include inside the LAYER object TOLERANCE and TOLERANCEUNITS.