Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Openlayers 3 Vaadin - GetFeatureInfoUrl
Hello, I am using OpenLayer 3 vaadin's demo and I meet some problems..
I implemented a ClickListerner on my map.
I would like to use GetFeatureInfoUrl with a single click on my map but I get the same url, no matter where I place the mouse.
Exemple 1 : I clicked on Nigeria, I get coordinates : 93.27
Exemple 2 : Then, I clicked on Sudan, I get the same cordinnates !!
Code example :
protected OLSource createSource() {
OLTileWMSSourceOptions options = new OLTileWMSSourceOptions();
// WebMapService of World http://www.osm-wms.de/
options.setUrl("http://129.206.228.72/osm-wms");
Map<String, String> params = new HashMap<String, String>();
params.put("LAYERS", "osm_auto:all");
params.put("FORMAT", "image/png");
options.setParams(params);
options.setGutter(2.0);
return new OLTileWMSSource(options);
}
protected OLView createView() {
OLViewOptions opts = new OLViewOptions();
// this is the projection this map server expects
// same as EPSG: 3857 but the map server does not recognize that...
opts.setMapProjection("EPSG:900913");
opts.setInputProjection(Projections.EPSG4326);
OLView view = new OLView(opts);
view.setZoom(4);
view.setCenter(0, 0);
view.setResolution(10000);
return view;
}
protected void doOnClick(OLMap.OLClickEvent clickEvent) {
for (int i = 0; i < clickEvent.getFeatureInfoUrls().size(); i++) {
System.out.println("i : " + i + " - " + clickEvent.getFeatureInfoUrls().get(i));
Notification.show("hey :"+excutePost(clickEvent.getFeatureInfoUrls().get(i), ""));
}
}
public static String excutePost(String targetURL, String urlParameters) {
HttpURLConnection connection = null;
try {
//Create connection
URL url = new URL(targetURL);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length",
Integer.toString(urlParameters.getBytes().length));
connection.setRequestProperty("Content-Language", "en-US");
connection.setUseCaches(false);
connection.setDoOutput(true);
//Send request
DataOutputStream wr = new DataOutputStream(
connection.getOutputStream());
wr.writeBytes(urlParameters);
wr.close();
//Get Response
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
StringBuilder response = new StringBuilder(); // or StringBuffer if not Java 5+
String line;
while ((line = rd.readLine()) != null) {
response.append(line);
response.append('\r');
}
rd.close();
return response.toString();
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (connection != null) {
connection.disconnect();
}
}
}
While coordinates of my mouse are different.. So I think, GetFeatureInfoUrl() doesn't take coordinates from my mouse. Do you have an idea ? thanks you !