2

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
11
  • You made sure WMS is enabled on your geoserver?
    – CaptDragon
    Commented Jul 22, 2011 at 16:31
  • Can you post firebugs response? or is it not present?
    – CaptDragon
    Commented Jul 22, 2011 at 16:32
  • @capdragon Hello! Yes WMS is enabled. The response section is blank.
    – Nate
    Commented Jul 22, 2011 at 16:46
  • 2
    is the page served from the same address as your geoserver? if not you'll need a proxy
    – Ian Turton
    Commented Jul 22, 2011 at 17:47
  • 1
    if the ports are different then you need a proxy or to relay the tomcat/geoserver through apache see ian01.geog.psu.edu/geoserver_docs/software/java.html
    – Ian Turton
    Commented Jul 23, 2011 at 10:04

1 Answer 1

2

So mostly for future readers of this question - when you are doing getFeatureInfo requests to a different server (which includes a difference in the port number) you need a proxy - see http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHost for more discussion.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.