How to retrieve WMS GetFeatureInfo from Openlayers & Geoserver


map.events.register('click', map, function (e) {
//alert(map.getExtent().toBBOX());
x1=parseInt(e.xy.x);
y1=parseInt(e.xy.y);
    var url = layerhost
      + "?REQUEST=GetFeatureInfo"
      + "&EXCEPTIONS=application/vnd.ogc.se_xml"
      + "&BBOX=" + map.getExtent().toBBOX()
      + "&X=" + x1
      + "&Y=" + y1
      + "&INFO_FORMAT=text/html"
      + "&QUERY_LAYERS=" + layername
      + "&LAYERS="+layername
      + "&FEATURE_COUNT=50"
      + "&SRS=EPSG:900913"
      + "&STYLES="
      + "&WIDTH=" + map.size.w
      + "&HEIGHT=" + map.size.h;
    window.open(url,
      "getfeatureinfo",
      "location=10,status=10,scrollbars=1,width=600,height=150"
    );
  });

I got  X and Y points due to floating point error while retrieving GetFeatureInfo . In order to prevent those errors I parse e.xy.x and e.xy.y values into integer, and it works for me.

Comments

Popular posts from this blog

Prevent WPF Global Keyboard Hook from stops working after hitting keys a while C# .NET

Generate ArcGIS Token By URL Request From ArcGIS Portal, Federated Environment , ESRI JS API and Angular snippets

Solution: IntelliJ not recognizing a particular file correctly, instead its stuck as a text file