Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using openlayers and Geoserver. I have created a base layer using OSM and then added wms layer topp:states. I want to show a world map and on that show US states. I have added onclick functionality to get feature info. However, when I click at any states, it gives incorrect state name or no result. This further worsens when I zoom in/zoom out or change the scale.Here is my code:


#map {

            position: relative;

            margin:0px ;


 var bounds = new OpenLayers.Bounds(

        format = 'image/png';

        var options = {
             controls: [],
            maxExtent: bounds,
            maxResolution: 0.22563114453125,
            projection: "EPSG:4326",
            units: 'degrees',
            displayProjection: new OpenLayers.Projection("EPSG:4326")

        map = new OpenLayers.Map('map', options);
        layer = new OpenLayers.Layer.OSM("Base OpenStreet Map");
     states = new OpenLayers.Layer.WMS(
            "NA states", "http://localhost:8080/geoserver/wms",
                layers: 'topp:states', styles: '', transparent: true,  format: 'image/png'
            { isBaseLayer: false, singleTile: false,displayOutsideMaxExtent: true, ratio: 1,yx : {'EPSG:4326' : true} }

Code with call to getfeatureInfo:'click', map, function (e) {
                            document.getElementById('nodelist').innerHTML =   "Loading... please wait...";
                                REQUEST: "GetFeatureInfo",
                                EXCEPTIONS: "application/vnd.ogc.se_xml",
                                BBOX: bounds.toBBOX(),
                                 SERVICE: "WMS",
                                INFO_FORMAT: 'text/html',
                                QUERY_LAYERS: [ map.layers[1].params.LAYERS],
                                FEATURE_COUNT: 50,
                                Layers: [map.layers[1].params.LAYERS],
                                 WIDTH: map.size.w,
                                HEIGHT: map.size.h,
                                x: Math.floor(e.xy.x),
                                 y: Math.floor(e.xy.y),

                               }, success:setHTML});

It may have to do with bounds or extents,but that's just my guess.

share|improve this question
Is your base map really in EPSG:4326? OSM data is usually EPSG:3857 (or some alias of that, like EPSG:900913) – BradHards Feb 18 '13 at 6:44
I am using following code to transform the bounds before making a call to getfeatureInfo: var EPSG4326 = new OpenLayers.Projection("EPSG:4326"); var EPSG900913 = new OpenLayers.Projection("EPSG:900913"); var bounds = map.getExtent().clone(); bounds = bounds.transform(EPSG900913, EPSG4326); – vyh Feb 18 '13 at 7:32
Since that isn't in the code above, it seems you might not have posted (all) the relevant code. Can you please edit your question to match the code you are actually trying to run? If its long, can you try hosting it somewhere public? – BradHards Feb 18 '13 at 8:52

Your Answer


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

Browse other questions tagged or ask your own question.