Thursday, November 17, 2011

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.

Geoserver , Openlayers , WMS

0 comments :

Post a Comment

 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me