# Leaflet WMS GetFeatureInfo gives result only on zoom level 10

I am using GetFeatureInfo with WMS layer to get the data behind. The request returns data only after zoom level 10 before that it returns empty features.

Does anyone having same issue?

I think it is not calculating correct X & Y until zoom level 10. If I look same on the OpenLayers demo viewer which comes with GeoServer it gives correct result.

Environment: -Leaflet 0.7.2 with GeoServer 2.5.1 serving WMS

Request sent on zoom level 9:

Request=GetFeatureInfo&EXCEPTIONS=application/vnd.ogc.se_xml&Layers=maps:dataLyr&SRS=EPSG:4326&BBOX=-163.8720703125,70.85998776061674,-159.2578125,71.67057415064292&SERVICE=WMS&width=1680&height=919&QUERY_LAYERS=maps:dataLyr&INFO_FORMAT=application/json&FEATURE_COUNT=50&&version=1.1.1&X=682&Y=388


Request sent on zoom level 10:

Request=GetFeatureInfo&EXCEPTIONS=application/vnd.ogc.se_xml&Layers=maps:dataLyr&SRS=EPSG:4326&BBOX=-162.96295166015625,71.09942906866509,-160.65582275390625,71.50400873687697&SERVICE=WMS&width=1680&height=919&QUERY_LAYERS=maps:dataLyr&INFO_FORMAT=application/json&FEATURE_COUNT=50&&version=1.1.1&X=701&Y=390


Result on zoom level 10:

• Please add this post as a comment to the answer and not as an answer itself. – Germán Carrillo Jan 29 '15 at 17:07

Solved this by using calculated X & Y instead of using generated from leaflet provided function layerPointToContainerPoint

Giving Wrong X & Y

var X =map.layerPointToContainerPoint(e.layerPoint).x.toFixed(0);
var Y = map.layerPointToContainerPoint(e.layerPoint).y.toFixed(0);

Correct X & Y from calculation

    var bds = map.getBounds();
var sz = map.getSize();
var w = bds.getNorthEast().lng - bds.getSouthWest().lng;
var h = bds.getNorthEast().lat - bds.getSouthWest().lat;
var X2= (((e.latlng.lng - bds.getSouthWest().lng) / w) * sz.x).toFixed(0);
var Y2 = (((bds.getNorthEast().lat - e.latlng.lat) / h) * sz.y).toFixed(0);