I'm having trouble with a select feature example in GeoServer and OpenLayers. For some reason the request returns nothing.
Here's the stripped down version that produces this:
I have a small WMS layer(~100 parcels) with polygons, and address data that I am overlaying Google Maps with a projection. It displays correctly.
map = map(...); //standard map creation
gmap = ...; // standard street map creation
wmslayer = new OpenLayers.Layer.WMS(
"Parcels",
"http://192.168.0.205/geoserver/wms",
{'layers': 'test:parcel', 'format':'image/png', 'transparent':'true'},
{'opacity': 0.5, 'isBaseLayer': false, 'visibility' : false, 'zoomMin' : 15}
);
Then I create the click control...
infoControls =
{
click: new OpenLayers.Control.WMSGetFeatureInfo
({
url: 'http://192.168.0.205/geoserver/wms',
title: 'Get parcel data',
layers: [wmslayer],
queryVisible: true
})
};
Added the layers, add the control and activate it
map.addLayers([gmap, wmslayer]);
infoControls[0].events.register("getfeatureinfo", this, showInfo);
map.addControl(infoControls[0]);
infoControls.click.activate();
//show info callback
function showInfo(evt) {
console.log(evt);
alert(evt.text);
}
But when I click on the map inside I parcel, it gives the alert is blank, and so is the features in Firebug (from console.log(evt)).
The GET request in Firebug is red.
BBOX -10845148.716676,5165071.048543,-10843335.725912,5166002.624825
FEATURE_COUNT 10
FORMAT image/png
HEIGHT 390
INFO_FORMAT text/html
LAYERS test:parcel
QUERY_LAYERS test:parcel
REQUEST GetFeatureInfo
SERVICE WMS
SRS EPSG:900913
STYLES
VERSION 1.1.1
WIDTH 759
X 582
Y 246
Edit: The database is CRS is EPSG:4327 and projecting it to Google Mercator... Do I need to project the BBOX of the request back to EPSG:4327 before I send the WMS request? How can I do this?
Here is the GeoServer log of the request
2011-07-22 14:49:01,301 INFO [geoserver.wms] -
Request: getFeatureInfo
GetMapRequest =
GetMap Request
version: 1.1.1
output format: image/png
width height: 759,390
bbox: ReferencedEnvelope[-1.0845637448332E7 : -1.0842011466804E7, 5164278.964868 : 5166142.117432]
layers: test:parcel
styles: polygon
QueryLayers = [org.geoserver.wms.MapLayerInfo@a837896f]
XPixel = 385
YPixel = 144
FeatureCount = 10
InfoFormat = text/html
Exceptions = application/vnd.ogc.se_xml
Version = 1.1.1
Request = GetFeatureInfo
BaseUrl = http://192.168.0.205:8080/geoserver/
Get = false
RawKvp = {INFO_FORMAT=text/html, BBOX=-10845637.448332,5164278.964868,-10842011.466804,5166142.117432, QUERY_LAYERS=test:parcel, SERVICE=WMS, HEIGHT=390, REQUEST=GetFeatureInfo, STYLES=, WIDTH=759, FEATURE_COUNT=10, VERSION=1.1.1, FORMAT=image/png, LAYERS=test:parcel, Y=144, X=385, SRS=EPSG:900913}
RequestCharset = null