OpenLayersWrapper, click event on the map with query to GeoServer data

I welcome!

I found that i can use code like this as an alternative event listener clicks on the map -


...
public class WMSClickListener {
	private VectorLayer vectorLayer;// 
	public WMSClickListener(final VectorLayer vectorLayer) {		
		this.vectorLayer = vectorLayer;
		
		vectorLayer.setDrawindMode(DrawingMode.POINT);		
		vectorLayer.addListener(new VectorDrawnListener() {
			 @Override
	         public void vectorDrawn(VectorDrawnEvent event) {
	             Vector vector = event.getVector();	             	             	             
	             Point[] points = vector.getPoints();	             	             
	             vectorLayer.getWindow().showNotification("Click on: " + points[0]
.getLon() + ", " + 
	            		 points[0]
.getLat());	             
	         }
	     });
	}
}
...

At the same time, if i click on the WMS that obtained with GeoServer (using OpenLayers.js API), i can see at a tabular form the objects it finds in the configured sources.
Perhaps, i use the wrapper to ensure the same result? What are the classes, methods should be used? Surely there is a way.:dry:

Does anyone know? :vader:

Operating with this information, click on the map, as well as an identifier of interest-GeoServer layer addresses configured as a source of spatial database and extracts all the necessary information, we can see in the “OpenLayers Map Preview”, click on WMS, produced by GeoServer:
12066.png

Request to GeoServer in this case is -

http://localhost:8082/geoserver/IntroGIS_WorkSpace/wms?

•REQUEST=GetFeatureInfo?&
•EXCEPTIONS=application%2Fvnd.ogc.se_xml&
•BBOX=-5.416416%2C36.012926%2C165.782416%2C74.735074&
•SERVICE=WMS&
•VERSION=1.1.1&
•X=671&
•Y=115&
•INFO_FORMAT=text%2Fhtml&
•QUERY_LAYERS=IntroGIS_WorkSpace%3Astans_small_map&FEATURE_COUNT=50&
•Layers=IntroGIS_WorkSpace%3Astans_small_map&
•WIDTH=1459&
•HEIGHT=330&
•format=image%2Fpng&styles=&
•srs=EPSG%3A4326

…the server responds -


<html>


<head>


<title>Geoserver GetFeatureInfo? output</title>


</head>
<style type="text/css">


table.featureInfo, table.featureInfo td, table.featureInfo th {


border:1px solid #ddd;
border-collapse:collapse;
margin:0;
padding:0;
font-size: 90%;
padding:.2em .1em;


}
table.featureInfo th {


padding:.2em .2em;


font-weight:bold;
background: #eee;


}
table.featureInfo td{


background: #fff;


}
table.featureInfo tr.odd td{


background: #eee;


}
table.featureInfo caption{


text-align:left;
font-size:100%;
font-weight:bold;
text-transform:uppercase;
padding:.2em .2em;


}


</style>
<body>



<table class="featureInfo">


<caption class="featureInfo">stans_small_map</caption>
<tr>
<th>fid</th>


<th >gid</th>
<th >objectid</th>
<th >kod</th>
<th >id</th>
<th >name</th>
<th >fullname</th>
<th >klass</th>
<th >sttype</th>


</tr>


<tr>


<td>stans_small_map.5</td> 


<td>5</td>
<td>67</td>
<td>79730</td>
<td>16777</td>
<td>Сургут</td>
<td>Сургут</td>
<td>2</td>
<td>0</td>


</tr>


</table>
<br/>


</body>


</html>


Actually the question - how to obtain these data using the OpenLayers Wrapper add-on?
I would be grateful for the information! :smiley:

Does anyone know? :glare:

Hi,

VectorLayer and drawing mode POINT can indeed be used as “click listener”. There has been an almost ready patch in queue also for several moths that would provide click listener support without requiring vector layer. The contributor has just been bit busy to finish it. He is using it to get location from a WMS layer, then querying WFS (Geoserver if I remember correctly) for features at that point and finally doing some amazing stuff with the data.

I hope you can deal with VectorLayer based solution until the patch lands.

cheers,
matti

The trick is to use a simple Java api to do the http request and parse the data somehow. Here is an example how to e.g. parse a WFS request:
http://stackoverflow.com/questions/2310139/how-to-read-xml-response-from-a-url-in-java

cheers,
matti

I welcome you, Matti Tahvonen!

Thank you very much for your help! :smiley: I’ll try to do so.

Cheers,
Thx