Discussion:
GetFeatureInfo requests never get answers
(too old to reply)
Marc Desharnais
2007-07-13 20:03:29 UTC
Permalink
Hi all,

I'm new to this mailing list. I work for the government of Canada on a
project to develop visualization tools.
I tried to adapt the example from

http://www.openlayers.org/dev/examples/getfeatureinfo.html


To get the getfeatureInfo working. I get the loading message in the div
section 'nodeList'. The problem is that it never seems to get an answer.
I get the checkpoint popup when I click the map so I guess that this
part is executed well. But it stays forever with the loading message.
So probably "wmsLayer1.getFullRequestString" is not correct or my
database is not quite right... I just have a layer with points.
And I want to query information about thoise points in the database to
display it beside the map.

I'm using a local Geoserver with PostGIS. I would like to know too how
the getFeatureInfo query works.
Like if I have anything I have to do specially into the database. I
figure that it's querying the database for info, but what info?
Do I have to define what I want to be queried? Maybe this is off-topic
here sorry.

I searched for informations on the UTIL package for openlayers but
didn't find real documentation about that.

Please let me know if you would like more info.


Any help will be greatly appreciated.
Thanks in advance





/******* CODE START HERE - !!! Note that this code is not complete. I
posted only the parts I found relevant. !!!
function init(){

var map = new OpenLayers.Map($('map'), {controls:[]} );
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;


var yahooLayer = new OpenLayers.Layer.Yahoo( "Globe (Yahoo)",
{reproject: "true"} );

map.addLayer(yahooLayer);


var wmsLayer1 = new OpenLayers.Layer.WMS(
"POSTGIS villes",
"http://ulysse.cmc.ec.gc.ca:8081/geoserver/wms",
{
layers: 'topp:villes',
format: 'image/png' , transparent: "true", reproject: "true"}
);


map.addLayer(wmsLayer1);


map.addControl(new OpenLayers.Control.LayerSwitcher());

map.addControl(new OpenLayers.Control.NavToolbar());
map.addControl(new OpenLayers.Control.PanZoomBar($('map')));

map.addControl(new OpenLayers.Control.MouseDefaults());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({element:
$('position')}));

map.events.register('click', map, function (e) {
OpenLayers.Util.getElement('nodeList').innerHTML =
"<b>Téléchargement d'information...<br> Veuillez Attendre SVP...</b>";
var url = wmsLayer1.getFullRequestString({
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: wmsLayer1.map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: wmsLayer1.params.LAYERS,
WIDTH: wmsLayer1.map.size.w,
HEIGHT: wmsLayer1.map.size.h});
OpenLayers.loadURL(url, '', this, setHTML);

alert("Checkpoint");

Event.stop(e);
});


}

function setHTML(response) {
alert("before answer");
OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;
alert("after answer");
}

/********* CODE STOPS HERE
Marc Desharnais
2007-07-18 14:42:43 UTC
Permalink
Hi all,

I wish to update my problem in hope to get more precise help.
I checked what is returned by the server and every time and do a manual
attempt by entering the request URL myself I get "no features were found".
Is it because of the server or from OpenLayers?
I tried to change the name of the layer in the reuqest to something
random, and I received a message telling that the feature type was not
found.

So I guess that it is querying the server with something that exists.
But it can't get any feature from the database. Again, if anyone has any
experience of OpenLayers getting layers from geoserver with PostGIS,
please tell me if there is anything to do in the database to make ot work.


Thank you :)

Marc
Hey Marc-
Post by Marc Desharnais
To get the getfeatureInfo working. I get the loading message in the
div section 'nodeList'. The problem is that it never seems to get an
answer.
I get the checkpoint popup when I click the map so I guess that this
part is executed well. But it stays forever with the loading message.
So probably "wmsLayer1.getFullRequestString" is not correct or my
database is not quite right... I just have a layer with points.
And I want to query information about thoise points in the database
to display it beside the map.
Since you are making an asynchronous request for the GetFeatureInfo
results, you are subject to the same origin policies that browsers
enforce.
This means that your GetFeatureInfo request won't go anywhere unless
it is requested with the same protocol, from the same port, and on the
same host as the request that initiated your application (see [1]).
If this sounds like your issue (i.e. you are making the request to
GeoServer on a different port than the request for the rest of your
application), see the FAQ on setting up a proxy host [2]. Note that
if you are using the proxy.cgi that comes in the OL examples
directory, you will need to add your host (and port) to the accepted
list (in proxy.cgi).
Post by Marc Desharnais
I'm using a local Geoserver with PostGIS. I would like to know too
how the getFeatureInfo query works.
Like if I have anything I have to do specially into the database. I
figure that it's querying the database for info, but what info?
Do I have to define what I want to be queried? Maybe this is
off-topic here sorry.
Also, use Firebug to watch the requests go out. Copy the request and
paste in to a new tab to make sure you are getting what you expect.
If you don't get what you expect, then you'll have to troubleshoot
your GeoServer configuration.
Hope that helps some,
Tim
[1] http://www.mozilla.org/projects/security/components/same-origin.html
[2] http://trac.openlayers.org/wiki/FrequentlyAskedQuestions#ProxyHost
Post by Marc Desharnais
I searched for informations on the UTIL package for openlayers but
didn't find real documentation about that.
Please let me know if you would like more info.
Any help will be greatly appreciated.
Thanks in advance
/******* CODE START HERE - !!! Note that this code is not complete. I
posted only the parts I found relevant. !!!
function init(){
var map = new OpenLayers.Map($('map'), {controls:[]} );
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
var yahooLayer = new
OpenLayers.Layer.Yahoo( "Globe (Yahoo)", {reproject: "true"} );
map.addLayer(yahooLayer);
var wmsLayer1 = new OpenLayers.Layer.WMS(
"POSTGIS villes",
"http://ulysse.cmc.ec.gc.ca:8081/geoserver/wms",
{
layers: 'topp:villes',
"true"}
);
map.addLayer(wmsLayer1);
map.addControl(new
OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.NavToolbar());
map.addControl(new OpenLayers.Control.PanZoomBar($('map')));
map.addControl(new OpenLayers.Control.MouseDefaults());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new
OpenLayers.Control.MousePosition({element: $('position')}));
map.events.register('click', map, function (e) {
OpenLayers.Util.getElement('nodeList').innerHTML =
"<b>Téléchargement d'information...<br> Veuillez Attendre SVP...</b>";
var url = wmsLayer1.getFullRequestString({
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: wmsLayer1.map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: wmsLayer1.params.LAYERS,
WIDTH: wmsLayer1.map.size.w,
HEIGHT: wmsLayer1.map.size.h});
OpenLayers.loadURL(url, '', this, setHTML);
alert("Checkpoint");
Event.stop(e);
});
}
function setHTML(response) {
alert("before answer");
OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;
alert("after answer");
}
/********* CODE STOPS HERE
_______________________________________________
Users mailing list
http://openlayers.org/mailman/listinfo/users
Brent Pedersen
2007-07-18 16:05:37 UTC
Permalink
hi,
in mapserver, you'd have to add something to make getfeatureinfo work
('ows_include_items') is that the case in geoserver?
have you checked if the &X , &Y url parameters look like the correct
pixel values.
then what does postgres log for the query from geoserver?
-b
Post by Marc Desharnais
Hi all,
I wish to update my problem in hope to get more precise help.
I checked what is returned by the server and every time and do a manual
attempt by entering the request URL myself I get "no features were found".
Is it because of the server or from OpenLayers?
I tried to change the name of the layer in the reuqest to something random,
and I received a message telling that the feature type was not found.
So I guess that it is querying the server with something that exists. But
it can't get any feature from the database. Again, if anyone has any
experience of OpenLayers getting layers from geoserver with PostGIS, please
tell me if there is anything to do in the database to make ot work.
Thank you :)
Marc
Hey Marc-
To get the getfeatureInfo working. I get the loading message in the div
section 'nodeList'. The problem is that it never seems to get an answer.
I get the checkpoint popup when I click the map so I guess that this part
is executed well. But it stays forever with the loading message.
So probably "wmsLayer1.getFullRequestString" is not correct or my database
is not quite right... I just have a layer with points.
And I want to query information about thoise points in the database to
display it beside the map.
Since you are making an asynchronous request for the GetFeatureInfo
results, you are subject to the same origin policies that browsers enforce.
This means that your GetFeatureInfo request won't go anywhere unless it is
requested with the same protocol, from the same port, and on the same host
as the request that initiated your application (see [1]).
If this sounds like your issue (i.e. you are making the request to
GeoServer on a different port than the request for the rest of your
application), see the FAQ on setting up a proxy host [2]. Note that if you
are using the proxy.cgi that comes in the OL examples directory, you will
need to add your host (and port) to the accepted list (in proxy.cgi).
I'm using a local Geoserver with PostGIS. I would like to know too how the
getFeatureInfo query works.
Like if I have anything I have to do specially into the database. I figure
that it's querying the database for info, but what info?
Do I have to define what I want to be queried? Maybe this is off-topic
here sorry.
Also, use Firebug to watch the requests go out. Copy the request and paste
in to a new tab to make sure you are getting what you expect. If you don't
get what you expect, then you'll have to troubleshoot your GeoServer
configuration.
Hope that helps some,
Tim
[1]
http://www.mozilla.org/projects/security/components/same-origin.html
[2]
http://trac.openlayers.org/wiki/FrequentlyAskedQuestions#ProxyHost
I searched for informations on the UTIL package for openlayers but didn't
find real documentation about that.
Please let me know if you would like more info.
Any help will be greatly appreciated.
Thanks in advance
/******* CODE START HERE - !!! Note that this code is not complete. I
posted only the parts I found relevant. !!!
function init(){
var map = new OpenLayers.Map($('map'), {controls:[]} );
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
var yahooLayer = new OpenLayers.Layer.Yahoo(
"Globe (Yahoo)", {reproject: "true"} );
map.addLayer(yahooLayer);
var wmsLayer1 = new OpenLayers.Layer.WMS(
"POSTGIS villes",
"http://ulysse.cmc.ec.gc.ca:8081/geoserver/wms",
{
layers: 'topp:villes',
format: 'image/png' , transparent: "true", reproject: "true"}
);
map.addLayer(wmsLayer1);
map.addControl(new
OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.NavToolbar());
map.addControl(new OpenLayers.Control.PanZoomBar($('map')));
map.addControl(new
OpenLayers.Control.MouseDefaults());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new
$('position')}));
map.events.register('click', map, function (e) {
OpenLayers.Util.getElement('nodeList').innerHTML =
"<b>Téléchargement d'information...<br> Veuillez Attendre SVP...</b>";
var url = wmsLayer1.getFullRequestString({
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: wmsLayer1.map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: wmsLayer1.params.LAYERS,
WIDTH: wmsLayer1.map.size.w,
HEIGHT: wmsLayer1.map.size.h});
OpenLayers.loadURL(url, '', this, setHTML);
alert("Checkpoint");
Event.stop(e);
});
}
function setHTML(response) {
alert("before answer");
OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;
alert("after answer");
}
/********* CODE STOPS HERE
_______________________________________________
Users mailing list
http://openlayers.org/mailman/listinfo/users
_______________________________________________
Users mailing list
http://openlayers.org/mailman/listinfo/users
Marc Desharnais
2007-07-19 13:04:34 UTC
Permalink
Hi,

I confirm that my geoserver is working fine. I exchanged some emails on
the geoserver mailing list and they suggested me to try the preview maps
given by geoserver. They now integer the getfeatureinfo functionality in
the default previews.

So I tried there and everything worked fine.

but, now, if I copy the html code entirely without any modification into
my webpage, I won't work. The map displays fine and everything. But it
hangs on the loading message and never get response. I used Firebug to
track the bug and I remarked that the request is never noticed in
firebug when I click on a point. The loadURL function is called but not
the setHTML. It makes me think that maybe it's a permission problem.
Since it semms to work from geoserver itself but not from apache (which
my web page is on).

Anyone had any experience like this?

Thank a lot,

Marc
Post by Brent Pedersen
hi,
in mapserver, you'd have to add something to make getfeatureinfo work
('ows_include_items') is that the case in geoserver?
have you checked if the &X , &Y url parameters look like the correct
pixel values.
then what does postgres log for the query from geoserver?
-b
Post by Marc Desharnais
Hi all,
I wish to update my problem in hope to get more precise help.
I checked what is returned by the server and every time and do a manual
attempt by entering the request URL myself I get "no features were found".
Is it because of the server or from OpenLayers?
I tried to change the name of the layer in the reuqest to something random,
and I received a message telling that the feature type was not found.
So I guess that it is querying the server with something that exists. But
it can't get any feature from the database. Again, if anyone has any
experience of OpenLayers getting layers from geoserver with PostGIS, please
tell me if there is anything to do in the database to make ot work.
Thank you :)
Marc
Hey Marc-
To get the getfeatureInfo working. I get the loading message in the div
section 'nodeList'. The problem is that it never seems to get an answer.
I get the checkpoint popup when I click the map so I guess that this part
is executed well. But it stays forever with the loading message.
So probably "wmsLayer1.getFullRequestString" is not correct or my database
is not quite right... I just have a layer with points.
And I want to query information about thoise points in the database to
display it beside the map.
Since you are making an asynchronous request for the GetFeatureInfo
results, you are subject to the same origin policies that browsers enforce.
This means that your GetFeatureInfo request won't go anywhere unless it is
requested with the same protocol, from the same port, and on the same host
as the request that initiated your application (see [1]).
If this sounds like your issue (i.e. you are making the request to
GeoServer on a different port than the request for the rest of your
application), see the FAQ on setting up a proxy host [2]. Note that if you
are using the proxy.cgi that comes in the OL examples directory, you will
need to add your host (and port) to the accepted list (in proxy.cgi).
I'm using a local Geoserver with PostGIS. I would like to know too how the
getFeatureInfo query works.
Like if I have anything I have to do specially into the database. I figure
that it's querying the database for info, but what info?
Do I have to define what I want to be queried? Maybe this is off-topic
here sorry.
Also, use Firebug to watch the requests go out. Copy the request and paste
in to a new tab to make sure you are getting what you expect. If you don't
get what you expect, then you'll have to troubleshoot your GeoServer
configuration.
Hope that helps some,
Tim
[1]
http://www.mozilla.org/projects/security/components/same-origin.html
[2]
http://trac.openlayers.org/wiki/FrequentlyAskedQuestions#ProxyHost
I searched for informations on the UTIL package for openlayers but didn't
find real documentation about that.
Please let me know if you would like more info.
Any help will be greatly appreciated.
Thanks in advance
/******* CODE START HERE - !!! Note that this code is not complete. I
posted only the parts I found relevant. !!!
function init(){
var map = new OpenLayers.Map($('map'), {controls:[]} );
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
var yahooLayer = new
OpenLayers.Layer.Yahoo(
"Globe (Yahoo)", {reproject: "true"} );
map.addLayer(yahooLayer);
var wmsLayer1 = new OpenLayers.Layer.WMS(
"POSTGIS villes",
"http://ulysse.cmc.ec.gc.ca:8081/geoserver/wms",
{
layers: 'topp:villes',
format: 'image/png' , transparent: "true", reproject: "true"}
);
map.addLayer(wmsLayer1);
map.addControl(new
OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.NavToolbar());
map.addControl(new OpenLayers.Control.PanZoomBar($('map')));
map.addControl(new
OpenLayers.Control.MouseDefaults());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new
$('position')}));
map.events.register('click', map, function (e) {
OpenLayers.Util.getElement('nodeList').innerHTML =
"<b>Téléchargement d'information...<br> Veuillez Attendre SVP...</b>";
var url = wmsLayer1.getFullRequestString({
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: wmsLayer1.map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: wmsLayer1.params.LAYERS,
WIDTH: wmsLayer1.map.size.w,
HEIGHT: wmsLayer1.map.size.h});
OpenLayers.loadURL(url, '', this, setHTML);
alert("Checkpoint");
Event.stop(e);
});
}
function setHTML(response) {
alert("before answer");
OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;
alert("after answer");
}
/********* CODE STOPS HERE
_______________________________________________
Users mailing list
http://openlayers.org/mailman/listinfo/users
_______________________________________________
Users mailing list
http://openlayers.org/mailman/listinfo/users
Christopher Schmidt
2007-07-19 13:20:33 UTC
Permalink
Post by Marc Desharnais
Hi,
I confirm that my geoserver is working fine. I exchanged some emails on
the geoserver mailing list and they suggested me to try the preview maps
given by geoserver. They now integer the getfeatureinfo functionality in
the default previews.
So I tried there and everything worked fine.
but, now, if I copy the html code entirely without any modification into
my webpage, I won't work. The map displays fine and everything. But it
hangs on the loading message and never get response. I used Firebug to
track the bug and I remarked that the request is never noticed in
firebug when I click on a point. The loadURL function is called but not
the setHTML. It makes me think that maybe it's a permission problem.
Since it semms to work from geoserver itself but not from apache (which
my web page is on).
http://trac.openlayers.org/wiki/FrequentlyAskedQuestions#WhydoIneedaProxyHost

Regards,
--
Christopher Schmidt
MetaCarta
Marc Desharnais
2007-07-19 15:48:05 UTC
Permalink
Hi Christopher,

Like you said, it turned out that the problem was a security issue.
To those who don't know (like me), you can't access a host with your
browser and make query on another. The point I was missing was that the
same machine with 2 different ports are considered to be 2 different
hosts. It's a simple explanation when you realize that.

I learned too why the security exception in Firefox while I attempted to
make request (via Firebug) didn't show like I would have expect.
That's a thing that really bothered me at the first place because I
would have expected an clear error from the browser.
I have read that this kind of exception are treated silently in the
browser so it's normal I've seen nothing while I was debugging.

Now everything is working well!

Thank you for your supportt! :)

Marc
Post by Christopher Schmidt
Post by Marc Desharnais
Hi,
I confirm that my geoserver is working fine. I exchanged some emails on
the geoserver mailing list and they suggested me to try the preview maps
given by geoserver. They now integer the getfeatureinfo functionality in
the default previews.
So I tried there and everything worked fine.
but, now, if I copy the html code entirely without any modification into
my webpage, I won't work. The map displays fine and everything. But it
hangs on the loading message and never get response. I used Firebug to
track the bug and I remarked that the request is never noticed in
firebug when I click on a point. The loadURL function is called but not
the setHTML. It makes me think that maybe it's a permission problem.
Since it semms to work from geoserver itself but not from apache (which
my web page is on).
http://trac.openlayers.org/wiki/FrequentlyAskedQuestions#WhydoIneedaProxyHost
Regards,
Christopher Schmidt
2007-07-19 16:42:29 UTC
Permalink
Post by Marc Desharnais
I learned too why the security exception in Firefox while I attempted to
make request (via Firebug) didn't show like I would have expect.
That's a thing that really bothered me at the first place because I
would have expected an clear error from the browser.
I have read that this kind of exception are treated silently in the
browser so it's normal I've seen nothing while I was debugging.
Actually, that's not entirely true. Instead, this is a failing of
OpenLayers.Ajax, which has since been corrected in trunk:

http://trac.openlayers.org/ticket/534

So, had you been using SVN, you would have seen "Unable to call
XMLHttpRequest.open".

Just for the record.

Regards,
--
Christopher Schmidt
MetaCarta
Tim Schaub
2007-07-24 23:01:49 UTC
Permalink
Hey Marc-

Glad you figured this out. Guess I should have put the same, protocol,
*same port*, and same host part in bold.

Hope others searching stumble across this sooner.
Since you are making an asynchronous request for the GetFeatureInfo
results, you are subject to the same origin policies that browsers enforce.
This means that your GetFeatureInfo request won't go anywhere unless it
is requested with the same protocol, from the same port, and on the same
host as the request that initiated your application (see [1]).
Hi Christopher,
Like you said, it turned out that the problem was a security issue.
To those who don't know (like me), you can't access a host with your
browser and make query on another. The point I was missing was that the
same machine with 2 different ports are considered to be 2 different
hosts. It's a simple explanation when you realize that.
I learned too why the security exception in Firefox while I attempted to
make request (via Firebug) didn't show like I would have expect.
That's a thing that really bothered me at the first place because I
would have expected an clear error from the browser.
I have read that this kind of exception are treated silently in the
browser so it's normal I've seen nothing while I was debugging.
Now everything is working well!
Thank you for your supportt! :)
Marc
Post by Christopher Schmidt
Post by Marc Desharnais
Hi,
I confirm that my geoserver is working fine. I exchanged some emails on
the geoserver mailing list and they suggested me to try the preview maps
given by geoserver. They now integer the getfeatureinfo functionality in
the default previews.
So I tried there and everything worked fine.
but, now, if I copy the html code entirely without any modification into
my webpage, I won't work. The map displays fine and everything. But it
hangs on the loading message and never get response. I used Firebug to
track the bug and I remarked that the request is never noticed in
firebug when I click on a point. The loadURL function is called but not
the setHTML. It makes me think that maybe it's a permission problem.
Since it semms to work from geoserver itself but not from apache (which
my web page is on).
http://trac.openlayers.org/wiki/FrequentlyAskedQuestions#WhydoIneedaProxyHost
Regards,
------------------------------------------------------------------------
_______________________________________________
Users mailing list
http://openlayers.org/mailman/listinfo/users
Continue reading on narkive:
Loading...