I have issue with getFeatureInfo function. I can get features of polygon only if it is clicked on line (border) of polygon. By clicking on line, i get features of few polygons, and i want to click inside of polygon and get feature info of that polygon, nothing else. I'm using Openlayers 2.13 and GeoServer. Where can i fix this?
Perhaps you are running GeoServer 2.5 and you have faced a bug that happened if there was no fill defined for polygons. Bug was resolved in GeoServer 2.5.2. Read more details from http://osgeo-org.1560.x6.nabble.com/WMS-GetFeatureInfo-with-Polygon-td5163455.html.
First aid would be to add fill to the polygon style. Updating GeoServer should be a definitive fix but if you already run GeoServer 2.6 or 2.7 then it could mean that the bug has popped up again.
I fixed problem by filling polygons with some color. Note: I'm running GeoServer 2.5.2 and bug is not fixed. But link above is very usefull, it helped me. Thanks to user30184.
<sld:Fill> <sld:CssParameter name="fill">#F6F4DB</sld:CssParameter> <sld:CssParameter name="fill-opacity">0.20</sld:CssParameter> </sld:Fill>
Add value of fill-opacity 0.20 something like that