Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm having trouble with a select feature example in Geoserver and open layers. 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 4327 and projecting it to Google Mercator... Do I need to project the BBox of the request back to 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
share|improve this question
    
You made sure WMS is enabled on your geoserver? –  CaptDragon Jul 22 '11 at 16:31
    
Can you post firebugs response? or is it not present? –  CaptDragon Jul 22 '11 at 16:32
    
@capdragon Hello! Yes WMS is enabled. The response section is blank. –  Nate Jul 22 '11 at 16:46
2  
is the page served from the same address as your geoserver? if not you'll need a proxy –  iant Jul 22 '11 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 –  iant Jul 23 '11 at 10:04

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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