Discussion:
How it works WMSGetFeatureInfo??
(too old to reply)
Francesc Cañas
2012-02-03 09:04:43 UTC
Permalink
Hi,

I want to use this control but i don't know how... I've found the same
information in all forums and tutorials but it doesn't work. What's wrong?
I've tried with diferents options and there's no way.


With pop-up:

info = new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://localhost:8080/geoserver/Proj_CAT/wms',
title: 'Identify features by clicking',
queryVisible: true,
eventListeners: {
getfeatureinfo: function(event) {
map.addPopup(new OpenLayers.Popup.FramedCloud(
"chicken",
map.getLonLatFromPixel(event.xy),
null,
event.text,
null,
true
));
}
}
});
map.addControl(info);
info.activate();


With text:

infoControls = {
click: new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://demo.opengeo.org/geoserver/wms',
title: 'Identify features by clicking',
layers: [water],
queryVisible: true
}),
hover: new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://demo.opengeo.org/geoserver/wms',
title: 'Identify features by clicking',
layers: [water],
hover: true,
// defining a custom format options here
formatOptions: {
typeName: 'water_bodies',
featureNS: 'http://www.openplans.org/topp'
},
queryVisible: true
})
}

infoControls.click.activate();
function showInfo(evt) { $('responseText').innerHTML = evt.text;}

And in the body: <div id="responseText"></div>


There's still more options and I've tried some of them with the same
result: The map is displayed but I can't display the layer info when I
click.

Thanks!
--
http://kikocanas.blogspot.com
Francesc Cañas
2012-02-06 08:19:26 UTC
Permalink
I think that layers are visible and also well projected, the map seems to
work but the control getfeatureinfo doesn't.

The complete code is the following, can you see something wrong? Thanks a
lot!



<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0,
maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>Prova visor auma</title>
<link rel="stylesheet" href="U:/Francesc/Proj_AUMA/html/style.css"
type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">





</head>

<body bgcolor=#F6E3CE onload="load()">
Projectes AUMA

<div id= "map"><div>
<div id=""resultTxt""></div>

</body>
</html>

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-it-works-WMSGetFeatureInfo-tp4361191p4368577.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Francesc Cañas
2012-02-06 09:35:21 UTC
Permalink
I run the map with the firebugs and it have found two erros but in the
OpenLayer.js, both are the same:


This size is null
if((origTL.x+this.size.w)>(mapSize.w-this.map.paddingForPopups.right)){newTL.x=mapSize.w-this.map.paddingForPopups.right-this.size.w;}

line 1759

What does it mean?

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-it-works-WMSGetFeatureInfo-tp4361191p4368728.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Max Stephan
2012-02-07 15:29:44 UTC
Permalink
Hi Francesc,

for debugging the error you get in Firebug I would recommend to use the
non-compressed OpenLayer-JS-files instead of the compressed ones - just
import the OpenLayer.js from the lib folder instead of that from the
"root"-folder and it will automatically import the single files. Anyway the
error doesn´t result from the WMSGetFeatureInfo-request itself but from the
popup-creation.

But apart from that error. Could you have a look into Firebug to see if you
even get a response from the server to your GetFeatureInfo-request? A very
common error is that the request is not possible due to the restrictions of
Javascript-cross-domain-policy (which means XML-HTTP-requests are only
allowed when the client-HTML-page and the server - GeoServer in this case -
are in the same domain). If your client and server should be in a different
domain you would need to implement a proxy to your server.

Best regards
Max Stephan

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-it-works-WMSGetFeatureInfo-tp4361191p4372878.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Francesc Cañas
2012-02-07 16:41:29 UTC
Permalink
Yes indeed, the root response is good, if I open the request in a new
windows it displays the layer info.I'll try what you say and I'll tell you.
Thanks a lot!
Post by Max Stephan
Hi Francesc,
for debugging the error you get in Firebug I would recommend to use the
non-compressed OpenLayer-JS-files instead of the compressed ones - just
import the OpenLayer.js from the lib folder instead of that from the
"root"-folder and it will automatically import the single files. Anyway the
error doesnÂŽt result from the WMSGetFeatureInfo-request itself but from the
popup-creation.
But apart from that error. Could you have a look into Firebug to see if
you even get a response from the server to your GetFeatureInfo-request? A
very common error is that the request is not possible due to the
restrictions of Javascript-cross-domain-policy (which means
XML-HTTP-requests are only allowed when the client-HTML-page and the server
- GeoServer in this case - are in the same domain). If your client and
server should be in a different domain you would need to implement a proxy
to your server.
Best regards
Max Stephan
------------------------------
If you reply to this email, your message will be added to the discussion
http://osgeo-org.1560.n6.nabble.com/How-it-works-WMSGetFeatureInfo-tp4361191p4372878.html
To unsubscribe from How it works WMSGetFeatureInfo??, click here<http://osgeo-org.1560.n6.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4361191&code=a2lrb2NhbmFzQGdtYWlsLmNvbXw0MzYxMTkxfC0xMDU3ODIxNDYx>
.
NAML<http://osgeo-org.1560.n6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
http://kikocanas.blogspot.com


--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-it-works-WMSGetFeatureInfo-tp4361191p4373142.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Francesc Cañas
2012-02-07 16:42:09 UTC
Permalink
The server response I mean.
Post by Francesc Cañas
Yes indeed, the root response is good, if I open the request in a new
windows it displays the layer info.I'll try what you say and I'll tell you.
Thanks a lot!
2012/2/7 Max Stephan [via OSGeo.org] <
Hi Francesc,
Post by Max Stephan
for debugging the error you get in Firebug I would recommend to use the
non-compressed OpenLayer-JS-files instead of the compressed ones - just
import the OpenLayer.js from the lib folder instead of that from the
"root"-folder and it will automatically import the single files. Anyway the
error doesnÂŽt result from the WMSGetFeatureInfo-request itself but from the
popup-creation.
But apart from that error. Could you have a look into Firebug to see if
you even get a response from the server to your GetFeatureInfo-request? A
very common error is that the request is not possible due to the
restrictions of Javascript-cross-domain-policy (which means
XML-HTTP-requests are only allowed when the client-HTML-page and the server
- GeoServer in this case - are in the same domain). If your client and
server should be in a different domain you would need to implement a proxy
to your server.
Best regards
Max Stephan
------------------------------
If you reply to this email, your message will be added to the
http://osgeo-org.1560.n6.nabble.com/How-it-works-WMSGetFeatureInfo-tp4361191p4372878.html
To unsubscribe from How it works WMSGetFeatureInfo??, click here<http://osgeo-org.1560.n6.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4361191&code=a2lrb2NhbmFzQGdtYWlsLmNvbXw0MzYxMTkxfC0xMDU3ODIxNDYx>
.
NAML<http://osgeo-org.1560.n6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
http://kikocanas.blogspot.com
--
http://kikocanas.blogspot.com


--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-it-works-WMSGetFeatureInfo-tp4361191p4373145.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Francesc Cañas
2012-02-08 08:53:59 UTC
Permalink
If I import the lib/openlayers.js <script
src="/OpenLayers/lib/OpenLayers.js"></script>
Firedebug says than Openlayers is not defined...

I have the OpenLayers folder inside the GeoServer folder, as well as the Web
File
--
http://kikocanas.blogspot.com
Francesc Cañas
2012-02-08 09:56:40 UTC
Permalink
I was comparing my html with the pop-up example and the only diference is
in the code: OpenLayers.ProxyHost = "proxy.cgi?url=";
So, in fact is a proxy bug...

I don't have any idea how the proxy works. Only for checking, i quit the
code of the example and firebugs says the same error that I have, "This
size is null ".
But i try to put the code in my file and it doesn't work at all.
What I have to do?
Thanks!!
Max Stephan
2012-02-08 21:33:31 UTC
Permalink
The path of OpenLayers.js must be relative to the location of your HTML-file.
Is that the case? What is Firebug showing you concerning the
OpenLayers-javascript? Is it loaded?

The ProxyHost-variable can be removed. You may only want to use it if you
have a proxy enabled (e.g. in your Apache). The variable is only pointing to
this proxy.

To test your HTML-file I´d recommend to put it into the www-folder of your
Geoserver (if that shouldn´t be the case already). By doing this you make
sure that you don´t get any cross-domain-policy-related problems. When you
launch the page you have to do it via a adress with this pattern
<url-of-your-geoserver>/www/<your-html-filename>.htm

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-it-works-WMSGetFeatureInfo-tp4361191p4377334.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Francesc Cañas
2012-02-09 09:11:43 UTC
Permalink
Thanks Max!

Well, I've removed the proxy-host-variable, so the code is the same as
before. Now I have the html-file and the openlayers-folder inside the
www-folder of geoserver and the path to the openlayers.js file relative to
html-file:

<script src="/OpenLayers/lib/OpenLayers.js"></script>

If I launch the page with http://localhost:8080/geoserver/www/popup.htm it
says

HTTP ERROR: 404
NOT_FOUND
RequestURI=/geoserver/www/popup.htm

If I open with mozilla, keep saying *OpenLayers is not defined*. It's the
only bug that shows...

If I keep the <script src="http://www.openlayers.org/api/OpenLayers.js">, I
either can launch the page via geoserver, but firebugs says that size is
null and displays:

http://localhost:8080/geoserver/Proj_CAT/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&LAYERS=Proj_CAT%3AProjectes_UTM31&QUERY_LAYERS=Proj_CAT%3AProjectes_UTM31&STYLES=&BBOX=-3.119873%2C38.473145%2C5.119873%2C43.526855&FEATURE_COUNT=10&HEIGHT=460&WIDTH=750&FORMAT=image%2Fpng&INFO_FORMAT=text%2Fhtml&SRS=EPSG%3A4326&X=357&Y=161

If I open the link, it shows the info that it supose to be inside the
popup. I really don't understand...


--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-it-works-WMSGetFeatureInfo-tp4361191p4378510.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
S Coetzer
2012-02-13 06:57:28 UTC
Permalink
Did you have any proxy issues?

Sarel
sarel
2012-02-27 06:28:51 UTC
Permalink
Sorry, I only read the last post from my email app.

I see most if these issues occur when developing outside the geoserver
application.
The whole idea behind WMS and getfeatureInfo is meant to be platform
independent.

You realy wonder what most users do with geoserver if they not realy using
WMSgetfeatureinfo facilities. I have read proxy issues dating back to 2007
only to find the are in the incorrect path not associated to geoserver path
(localhost:8080/geoserver/www/xxx)

I see the WMSgetFeatureInfo one of the most attractive facilities in any map
server.

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-it-works-WMSGetFeatureInfo-tp4361191p4513670.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Francesc Cañas
2012-02-10 12:35:45 UTC
Permalink
With the getfeatureinfo-controls version, I get the map with the layer but
when I click to get info nothing happens.

Firebugs don't get any error and show the request. And if I open it have
the layer info that I want to display beside the map.

http://localhost:8080/geoserver/Proj_CAT/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&LAYERS=Proj_CAT%3AProjectes_UTM31&QUERY_LAYERS=Proj_CAT%3AProjectes_UTM31&STYLES=&BBOX=-3.174805%2C38.253418%2C5.174805%2C43.746582&FEATURE_COUNT=10&HEIGHT=500&WIDTH=760&FORMAT=image%2Fpng&INFO_FORMAT=text%2Fhtml&SRS=EPSG%3A4326&X=455&Y=150


I also have this version in the /www/ folder with the openlayers.js online
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>

If I try to use the downloaded version at www/openlayers/lib/openlayers.js
also says that OpenLayers is not defined


The whole code is this:

<!DOCTYPE html>
<html>
<head>

<title>Prova visor auma</title>

<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<link rel="stylesheet" href="C:/OpenLayers-2.11/theme/default/style.css"
type="text/css">

<style type="text/css">

#map{ height: 500px;
width: 760px;
margin:20px;

}
#info {
position: absolute;
left:80%;
top:15%;
}
#info table td {
border:1px solid #ddd;
border-collapse: collapse;
margin: 0;
padding: 0;
font-size: 90%;
padding: .2em .1em;
background:#fff;
}
#info table th{
padding:.2em .2em;
text-transform: uppercase;
font-weight: bold;
background: #eee;
}
tr.odd td {
background:#eee;
}
table.featureInfo caption {
text-align:left;
font-size:100%;
font-weight:bold;
padding:.2em .2em;
}
</style>
<script defer="defer" type="text/javascript">

var map, highlightlayer;

function load(){

var options = {
controls: [new OpenLayers.Control.KeyboardDefaults(),
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.ScaleLine(),
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.OverviewMap(),
new OpenLayers.Control.MousePosition()
]
};
map = new OpenLayers.Map('map', options);
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0?",
{layers: 'basic'}
);
var Projectes_Cat = new OpenLayers.Layer.WMS(
"Projectes UTM31",
"http://localhost:8080/geoserver/Proj_CAT/wms",
{
layers: 'Proj_CAT:Projectes_UTM31',transparent:
'true',isBaseLayer:"false"
}
);
highlightLayer = new OpenLayers.Layer.Vector("Highlighted Features", {
displayInLayerSwitcher: false,
isBaseLayer: false
}
);
map.addLayers ([wms, Projectes_Cat, highlightLayer]);
map.setCenter (new OpenLayers.LonLat (1,41), 7);


infoControls = {
click: new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://localhost:8080/geoserver/Proj_CAT/wms',
title: 'Identify features by clicking',
layers: [Projectes_Cat],
queryVisible: true
}),
}
for (var i in infoControls) {
infoControls[i].events.register("getfeatureinfo", this,
showInfo);
map.addControl(infoControls[i]);
}
infoControls.click.activate();
}
function showInfo(evt) {
if (evt.features && evt.features.length) {
highlightLayer.destroyFeatures();
highlightLayer.addFeatures(evt.features);
highlightLayer.redraw();
} else {
$('responseText').innerHTML = evt.text;
}
}
</script>
</head>


<body bgcolor=#F6E3CE onload="load()">

<h1> Visor dels Projectes d'AUMA</h1>

<div id= "map"><div>

<div id="info">
<h3>Info dels Projectes</h3>
<p><small>Click sobre els punts per detalls del projecte</small></p>
<div id="responseText"></div>
</div>


</body>
</html>


I'm running out of ideas...
--
http://kikocanas.blogspot.com


--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-it-works-WMSGetFeatureInfo-tp4361191p4383169.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Francesc Cañas
2012-02-12 20:07:03 UTC
Permalink
Good news, (in some way)

Tired to go nowhere with my personal battle with geoserver, I've tried to
make exactly the same in another computer and it works...

The only diference, first one is Vista, second one Xp

Thanks for all!!
--
http://kikocanas.blogspot.com


--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-it-works-WMSGetFeatureInfo-tp4361191p4463002.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
Continue reading on narkive:
Loading...