I have tried to send manual WMS GetFeatureInfo request to GeoServer with the parameter values X and Y (pixel values) taken from the map object of OpenLayers.

I have got the response with the wrong values which is not matched with the values I have seen in the GeoServer preview with the same long/lat.

The requested URL was:


I have referred with these posts also: Can Geoserver return the raster value of a lat/lon point.

Is there any possible way to give the clicked long/lat values given instead of X and Y pixel values in a GeoServer WMS GetFeatureInfo request?


What are the factors which are to be clear when making this request manually. More particular width, height and the BBOX values?

In client side I have made an AJAX call:

map.events.register("click",this, function(e){

    var clickedLatLong =map.getLonLatFromViewPortPx(e.xy);
    var clickedPixel =  map.getPixelFromLonLat(clickedLatLong);
    if(!map.getMaxExtent().containsLonLat(clickedLatLong)) {

        var bbox = map.getExtent();
            type: 'GET',
            url: 'getMultiLayersValue.html',    
            dataType: 'html',

            success : function(result){
                $("#DisplayResponse").dialog( "open" );

            complete:function(xhr, txtStatus){

            error: function(xhr, error){
                alert("Taking More Time to Respond\n Please Try Later or Contact System Administrator");

In server side I have made this URL request:


Eventually no error messages were found only I got the wrong values for my clicked long/lat. May be the values of pixel getting wrong but I unable to find the solutions.

  • post some code and error messages
    – Gery
    Commented Dec 2, 2013 at 15:02
  • @grey I have added some code were i used to get the pixel or long/lat in clientside programming.And also the url at server side coding.No error messages were found only response values from the wrong pixels.
    – AshokDev
    Commented Dec 4, 2013 at 6:30
  • How do you know they are "wrong"? Have you looked at docs.geoserver.org/stable/en/user/services/wms/… ? If you want to get features by bounding box, perhaps you really wanted to use a WFS GetFeature query?
    – BradHards
    Commented Dec 4, 2013 at 7:22
  • If you want the features at at particular Lat & Long, it would be a better idea to use the GetFeatures on the WFS service. Commented Dec 4, 2013 at 9:07
  • could you post a real example with some values? I don't use geoserver, so I can't tell you if that's the problem, but it seems that these ones var clickedLatLong =map.getLonLatFromViewPortPx(e.xy); var clickedPixel = map.getPixelFromLonLat(clickedLatLong); have some responsibility
    – Gery
    Commented Dec 4, 2013 at 20:51

2 Answers 2


Yes, see this answer: https://gis.stackexchange.com/a/211562/3399

This is the JavaScript implementation:

var parameters = {
  service: 'WMS',
  version: '1.1.1',
  request: 'GetFeatureInfo',
  layers: currentLayer,
  query_layers: currentLayer,
  feature_count: 10,
  info_format: 'text/javascript',
  format_options: 'callback:handleJson',
  SrsName: 'EPSG:4326',
  width: 101,
  height: 101,
  x: 50,
  y: 50,
  bbox: (lng - 0.1) + ',' + (lat - 0.1) + ',' + (lng + 0.1) + ',' + (lat + 0.1)
var url = owsurl + L.Util.getParamString(parameters)
  url: owsurl + L.Util.getParamString(parameters),
  dataType: 'jsonp',
  success: function (data) {

Basically, you use the lat, lon to create a bounding box, and select the values in the middle of it. You can return JSON, which you can eat up with your code.


Is there any possible ways to give the clicked long/lat values given instead of X and Y pixel values in the geoserver wms getfeatureinfo request??


A WMS GetFeatureInfo request is, by definition, a request for the data values at an image coordinate in a GetMap request (which always returns an image). In effect, the majority of the request parameters define the GetMap request and the X,Y (WMS 1.1.1) or I,J (WMS 1.3.0) defines the image coordinate.

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.