Discussion:
[OpenLayers-Users] GetFeatureInfo
Nina Helle-Mildt
2008-10-31 10:59:56 UTC
Permalink
Hi there,

a couple of weeks ago I already posted a mail on querying layers using
the GetFeatureUnfo request. Many thanks to all of you who tried to help
me! Nevertheless I'm still struggeling with this task:

I have two overlay layers (both wms layers) displaying point data. What
I want to do is, clicking a point object of one of the two layers with
the mouse in order to get the results of this query displayed in an
defined area next to the map.

I would appreciate any help - a complete example would be great!

Best regards
Nina


Below parts of my code:

//Overlay Layers:
var seis = new OpenLayers.Layer.WMS.Untiled("Erdbeben weltweit ",
"http://www.seismologie.bgr.de:8080/cgi-bin/mapserv?map=seis_wms.map",
{transparent: 'true', layers:
['q_year','q_month','q_week','aktuell_welt']},
{'buffer': 1},
{singleTile: true, 'ratio': 1.0},
{'isBaseLayer': false, 'gutter': 20});

var seis_ger = new OpenLayers.Layer.WMS.Untiled("Erdbeben
Deutschland",
"http://www.seismologie.bgr.de:8080/cgi-bin/mapserv?map=seis_d_wms.map",
{transparent: 'true', layers:
['q_year_ger','q_month_ger','q_week_ger',
'aktuell_ger','box']},
{'buffer': 1},
{singleTile: true, 'ratio': 1.0},
{'isBaseLayer': false, 'gutter': 20});

...

//Support GetFeatureInfo

map.events.register('click', map, function (e) {
document.getElementById('nodeList').innerHTML = "Einen Moment bitte ...";
var url = map.layers[0].getFullRequestString(
{
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: map.layers[0].params.LAYERS,
FEATURE_COUNT: 50,
WIDTH: map.size.w,
HEIGHT: map.size.h}
);

OpenLayers.loadURL(url, '', this, setHTML);
OpenLayers.Event.stop(e);
});
function setHTML(response) {
OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;}




//Support GetFeatureInfo - this Version (works great with only 1 layer)

// map.events.register('click', map, function (e) {
// //document.getElementById('map').style.cursor = 'crosshair';
// OpenLayers.Util.getElement('nodeList').innerHTML = "Einen Moment
bitte ...";
// var url = seis.getFullRequestString({
// REQUEST: "GetFeatureInfo",
// EXCEPTIONS: "application/vnd.ogc.se_xml",
// BBOX: seis.map.getExtent().toBBOX(),
// X: e.xy.x,
// Y: e.xy.y,
// INFO_FORMAT: 'text/html',
// QUERY_LAYERS: seis.params.LAYERS,
// WIDTH: seis.map.size.w,
// HEIGHT: seis.map.size.h});
// OpenLayers.loadURL(url, '', this, setHTML); //alternativ:
window.open(url);
// OpenLayers.Event.stop(e);
// });
// function setHTML(response) {
// OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;}
Indika Tantrigoda
2008-10-31 17:15:06 UTC
Permalink
Hi,
I too had the same problem, but it was with a wfs point layer.
I was able to get around this by using selectFeature (thanks to all on the
list who helped me out)

Check this out
http://www.nabble.com/WFS-Layers%2C-Markers%2C-Popups-to20189787.html

Maybe this could give you a clue.

Regards,
Indika
Post by Nina Helle-Mildt
Hi there,
a couple of weeks ago I already posted a mail on querying layers using
the GetFeatureUnfo request. Many thanks to all of you who tried to help
I have two overlay layers (both wms layers) displaying point data. What
I want to do is, clicking a point object of one of the two layers with
the mouse in order to get the results of this query displayed in an
defined area next to the map.
I would appreciate any help - a complete example would be great!
Best regards
Nina
var seis = new OpenLayers.Layer.WMS.Untiled("Erdbeben weltweit ",
"http://www.seismologie.bgr.de:8080/cgi-bin/mapserv?map=seis_wms.map",
['q_year','q_month','q_week','aktuell_welt']},
{'buffer': 1},
{singleTile: true, 'ratio': 1.0},
{'isBaseLayer': false, 'gutter': 20});
var seis_ger = new OpenLayers.Layer.WMS.Untiled("Erdbeben
Deutschland",
"http://www.seismologie.bgr.de:8080/cgi-bin/mapserv?map=seis_d_wms.map",
['q_year_ger','q_month_ger','q_week_ger',
'aktuell_ger','box']},
{'buffer': 1},
{singleTile: true, 'ratio': 1.0},
{'isBaseLayer': false, 'gutter': 20});
...
//Support GetFeatureInfo
map.events.register('click', map, function (e) {
document.getElementById('nodeList').innerHTML = "Einen Moment bitte ...";
var url = map.layers[0].getFullRequestString(
{
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: map.layers[0].params.LAYERS,
FEATURE_COUNT: 50,
WIDTH: map.size.w,
HEIGHT: map.size.h}
);
OpenLayers.loadURL(url, '', this, setHTML);
OpenLayers.Event.stop(e);
});
function setHTML(response) {
OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;}
//Support GetFeatureInfo - this Version (works great with only 1 layer)
// map.events.register('click', map, function (e) {
// //document.getElementById('map').style.cursor = 'crosshair';
// OpenLayers.Util.getElement('nodeList').innerHTML = "Einen Moment
bitte ...";
// var url = seis.getFullRequestString({
// REQUEST: "GetFeatureInfo",
// EXCEPTIONS: "application/vnd.ogc.se_xml",
// BBOX: seis.map.getExtent().toBBOX(),
// X: e.xy.x,
// Y: e.xy.y,
// INFO_FORMAT: 'text/html',
// QUERY_LAYERS: seis.params.LAYERS,
// WIDTH: seis.map.size.w,
// HEIGHT: seis.map.size.h});
// OpenLayers.loadURL(url, '', this, setHTML);
window.open(url);
// OpenLayers.Event.stop(e);
// });
// function setHTML(response) {
// OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;}
_______________________________________________
Users mailing list
http://openlayers.org/mailman/listinfo/users
Indika Tantrigoda
2008-10-31 17:28:17 UTC
Permalink
Hi Eric,
Thanks for the info, didn't know that.
SelectFeature won't help with WMS layers. Eric
Post by Indika Tantrigoda
Hi,
I too had the same problem, but it was with a wfs point layer.
I was able to get around this by using selectFeature (thanks to all on
the
Post by Indika Tantrigoda
list who helped me out)
Check this out
http://www.nabble.com/WFS-Layers%2C-Markers%2C-Popups-to20189787.html
Maybe this could give you a clue.
Regards,
Indika
Post by Nina Helle-Mildt
Hi there,
a couple of weeks ago I already posted a mail on querying layers using
the GetFeatureUnfo request. Many thanks to all of you who tried to help
I have two overlay layers (both wms layers) displaying point data. What
I want to do is, clicking a point object of one of the two layers with
the mouse in order to get the results of this query displayed in an
defined area next to the map.
I would appreciate any help - a complete example would be great!
Best regards
Nina
var seis = new OpenLayers.Layer.WMS.Untiled("Erdbeben weltweit ",
"http://www.seismologie.bgr.de:8080/cgi-bin/mapserv?map=seis_wms.map",
['q_year','q_month','q_week','aktuell_welt']},
{'buffer': 1},
{singleTile: true, 'ratio': 1.0},
{'isBaseLayer': false, 'gutter': 20});
var seis_ger = new OpenLayers.Layer.WMS.Untiled("Erdbeben
Deutschland",
"http://www.seismologie.bgr.de:8080/cgi-bin/mapserv?map=seis_d_wms.map
",
Post by Indika Tantrigoda
Post by Nina Helle-Mildt
['q_year_ger','q_month_ger','q_week_ger',
'aktuell_ger','box']},
{'buffer': 1},
{singleTile: true, 'ratio': 1.0},
{'isBaseLayer': false, 'gutter': 20});
...
//Support GetFeatureInfo
map.events.register('click', map, function (e) {
document.getElementById('nodeList').innerHTML = "Einen Moment bitte
...";
Post by Indika Tantrigoda
Post by Nina Helle-Mildt
var url = map.layers[0].getFullRequestString(
{
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: map.layers[0].params.LAYERS,
FEATURE_COUNT: 50,
WIDTH: map.size.w,
HEIGHT: map.size.h}
);
OpenLayers.loadURL(url, '', this, setHTML);
OpenLayers.Event.stop(e);
});
function setHTML(response) {
OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;}
//Support GetFeatureInfo - this Version (works great with only 1 layer)
// map.events.register('click', map, function (e) {
// //document.getElementById('map').style.cursor = 'crosshair';
// OpenLayers.Util.getElement('nodeList').innerHTML = "Einen Moment
bitte ...";
// var url = seis.getFullRequestString({
// REQUEST: "GetFeatureInfo",
// EXCEPTIONS: "application/vnd.ogc.se_xml",
// BBOX: seis.map.getExtent().toBBOX(),
// X: e.xy.x,
// Y: e.xy.y,
// INFO_FORMAT: 'text/html',
// QUERY_LAYERS: seis.params.LAYERS,
// WIDTH: seis.map.size.w,
// HEIGHT: seis.map.size.h});
// OpenLayers.loadURL(url, '', this, setHTML);
window.open(url);
// OpenLayers.Event.stop(e);
// });
// function setHTML(response) {
// OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;}
_______________________________________________
Users mailing list
http://openlayers.org/mailman/listinfo/users
Eric Lemoine
2008-10-31 17:25:11 UTC
Permalink
SelectFeature won't help with WMS layers. Eric
Post by Indika Tantrigoda
Hi,
I too had the same problem, but it was with a wfs point layer.
I was able to get around this by using selectFeature (thanks to all on the
list who helped me out)
Check this out
http://www.nabble.com/WFS-Layers%2C-Markers%2C-Popups-to20189787.html
Maybe this could give you a clue.
Regards,
Indika
Post by Nina Helle-Mildt
Hi there,
a couple of weeks ago I already posted a mail on querying layers using
the GetFeatureUnfo request. Many thanks to all of you who tried to help
I have two overlay layers (both wms layers) displaying point data. What
I want to do is, clicking a point object of one of the two layers with
the mouse in order to get the results of this query displayed in an
defined area next to the map.
I would appreciate any help - a complete example would be great!
Best regards
Nina
var seis = new OpenLayers.Layer.WMS.Untiled("Erdbeben weltweit ",
"http://www.seismologie.bgr.de:8080/cgi-bin/mapserv?map=seis_wms.map",
['q_year','q_month','q_week','aktuell_welt']},
{'buffer': 1},
{singleTile: true, 'ratio': 1.0},
{'isBaseLayer': false, 'gutter': 20});
var seis_ger = new OpenLayers.Layer.WMS.Untiled("Erdbeben
Deutschland",
"http://www.seismologie.bgr.de:8080/cgi-bin/mapserv?map=seis_d_wms.map",
['q_year_ger','q_month_ger','q_week_ger',
'aktuell_ger','box']},
{'buffer': 1},
{singleTile: true, 'ratio': 1.0},
{'isBaseLayer': false, 'gutter': 20});
...
//Support GetFeatureInfo
map.events.register('click', map, function (e) {
document.getElementById('nodeList').innerHTML = "Einen Moment bitte ...";
var url = map.layers[0].getFullRequestString(
{
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: map.layers[0].params.LAYERS,
FEATURE_COUNT: 50,
WIDTH: map.size.w,
HEIGHT: map.size.h}
);
OpenLayers.loadURL(url, '', this, setHTML);
OpenLayers.Event.stop(e);
});
function setHTML(response) {
OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;}
//Support GetFeatureInfo - this Version (works great with only 1 layer)
// map.events.register('click', map, function (e) {
// //document.getElementById('map').style.cursor = 'crosshair';
// OpenLayers.Util.getElement('nodeList').innerHTML = "Einen Moment
bitte ...";
// var url = seis.getFullRequestString({
// REQUEST: "GetFeatureInfo",
// EXCEPTIONS: "application/vnd.ogc.se_xml",
// BBOX: seis.map.getExtent().toBBOX(),
// X: e.xy.x,
// Y: e.xy.y,
// INFO_FORMAT: 'text/html',
// QUERY_LAYERS: seis.params.LAYERS,
// WIDTH: seis.map.size.w,
// HEIGHT: seis.map.size.h});
// OpenLayers.loadURL(url, '', this, setHTML);
window.open(url);
// OpenLayers.Event.stop(e);
// });
// function setHTML(response) {
// OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;}
_______________________________________________
Users mailing list
http://openlayers.org/mailman/listinfo/users
Arnd Wippermann
2008-10-31 18:07:43 UTC
Permalink
I would try something like this:

var url = seis.getFullRequestString( ....
var url2 = seis_ger.getFullRequestString( ....

OpenLayers.loadURL(url, '', this, setHTML);
OpenLayers.Event.stop(e);
});
function setHTML(response) {
OpenLayers.Util.getElement('nodeList').innerHTML +=
response.responseText;}

OpenLayers.loadURL(url2, '', this, setHTML);
OpenLayers.Event.stop(e);
});
function setHTML(response) {
OpenLayers.Util.getElement('nodeList').innerHTML +=
response.responseText;}

You have to request both layers. Perhaps it works.

Arnd Wippermann


-----Ursprüngliche Nachricht-----
Von: users-***@openlayers.org [mailto:users-***@openlayers.org] Im
Auftrag von Nina Helle-Mildt
Gesendet: Freitag, 31. Oktober 2008 12:00
An: OpenLayers
Betreff: [OpenLayers-Users] GetFeatureInfo

Hi there,

a couple of weeks ago I already posted a mail on querying layers using the
GetFeatureUnfo request. Many thanks to all of you who tried to help me!
Nevertheless I'm still struggeling with this task:

I have two overlay layers (both wms layers) displaying point data. What I
want to do is, clicking a point object of one of the two layers with the
mouse in order to get the results of this query displayed in an defined area
next to the map.

I would appreciate any help - a complete example would be great!

Best regards
Nina


Below parts of my code:

//Overlay Layers:
var seis = new OpenLayers.Layer.WMS.Untiled("Erdbeben weltweit ",
"http://www.seismologie.bgr.de:8080/cgi-bin/mapserv?map=seis_wms.map",
{transparent: 'true', layers:
['q_year','q_month','q_week','aktuell_welt']},
{'buffer': 1},
{singleTile: true, 'ratio': 1.0},
{'isBaseLayer': false, 'gutter': 20});

var seis_ger = new OpenLayers.Layer.WMS.Untiled("Erdbeben
Deutschland",
"http://www.seismologie.bgr.de:8080/cgi-bin/mapserv?map=seis_d_wms.map",
{transparent: 'true', layers:
['q_year_ger','q_month_ger','q_week_ger',
'aktuell_ger','box']},
{'buffer': 1},
{singleTile: true, 'ratio': 1.0},
{'isBaseLayer': false, 'gutter': 20});

...

//Support GetFeatureInfo

map.events.register('click', map, function (e) {
document.getElementById('nodeList').innerHTML = "Einen Moment bitte ...";
var url = map.layers[0].getFullRequestString(
{
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: map.layers[0].params.LAYERS,
FEATURE_COUNT: 50,
WIDTH: map.size.w,
HEIGHT: map.size.h}
);

OpenLayers.loadURL(url, '', this, setHTML);
OpenLayers.Event.stop(e);
});
function setHTML(response) {
OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;}




//Support GetFeatureInfo - this Version (works great with only 1 layer)

// map.events.register('click', map, function (e) {
// //document.getElementById('map').style.cursor = 'crosshair';
// OpenLayers.Util.getElement('nodeList').innerHTML = "Einen Moment
bitte ...";
// var url = seis.getFullRequestString({
// REQUEST: "GetFeatureInfo",
// EXCEPTIONS: "application/vnd.ogc.se_xml",
// BBOX: seis.map.getExtent().toBBOX(),
// X: e.xy.x,
// Y: e.xy.y,
// INFO_FORMAT: 'text/html',
// QUERY_LAYERS: seis.params.LAYERS,
// WIDTH: seis.map.size.w,
// HEIGHT: seis.map.size.h});
// OpenLayers.loadURL(url, '', this, setHTML);
//alternativ:
window.open(url);
// OpenLayers.Event.stop(e);
// });
// function setHTML(response) {
// OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;}
Nina Helle-Mildt
2008-11-04 14:31:45 UTC
Permalink
Hi to all,

thanks a lot to all of you who gave me some ideas. I tried the way Arnd
Wippermann suggested and it seems as if one of my WMS isn't correct. So
I have to go back to UMN MapServer ...

Regards
Nina
Post by Arnd Wippermann
var url = seis.getFullRequestString( ....
var url2 = seis_ger.getFullRequestString( ....
OpenLayers.loadURL(url, '', this, setHTML);
OpenLayers.Event.stop(e);
});
function setHTML(response) {
OpenLayers.Util.getElement('nodeList').innerHTML +=
response.responseText;}
OpenLayers.loadURL(url2, '', this, setHTML);
OpenLayers.Event.stop(e);
});
function setHTML(response) {
OpenLayers.Util.getElement('nodeList').innerHTML +=
response.responseText;}
You have to request both layers. Perhaps it works.
Arnd Wippermann
-----Ursprüngliche Nachricht-----
Auftrag von Nina Helle-Mildt
Gesendet: Freitag, 31. Oktober 2008 12:00
An: OpenLayers
Betreff: [OpenLayers-Users] GetFeatureInfo
Hi there,
a couple of weeks ago I already posted a mail on querying layers using the
GetFeatureUnfo request. Many thanks to all of you who tried to help me!
I have two overlay layers (both wms layers) displaying point data. What I
want to do is, clicking a point object of one of the two layers with the
mouse in order to get the results of this query displayed in an defined area
next to the map.
I would appreciate any help - a complete example would be great!
Best regards
Nina
var seis = new OpenLayers.Layer.WMS.Untiled("Erdbeben weltweit ",
"http://www.seismologie.bgr.de:8080/cgi-bin/mapserv?map=seis_wms.map",
['q_year','q_month','q_week','aktuell_welt']},
{'buffer': 1},
{singleTile: true, 'ratio': 1.0},
{'isBaseLayer': false, 'gutter': 20});
var seis_ger = new OpenLayers.Layer.WMS.Untiled("Erdbeben
Deutschland",
"http://www.seismologie.bgr.de:8080/cgi-bin/mapserv?map=seis_d_wms.map",
['q_year_ger','q_month_ger','q_week_ger',
'aktuell_ger','box']},
{'buffer': 1},
{singleTile: true, 'ratio': 1.0},
{'isBaseLayer': false, 'gutter': 20});
...
//Support GetFeatureInfo
map.events.register('click', map, function (e) {
document.getElementById('nodeList').innerHTML = "Einen Moment bitte ...";
var url = map.layers[0].getFullRequestString(
{
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: map.layers[0].params.LAYERS,
FEATURE_COUNT: 50,
WIDTH: map.size.w,
HEIGHT: map.size.h}
);
OpenLayers.loadURL(url, '', this, setHTML);
OpenLayers.Event.stop(e);
});
function setHTML(response) {
OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;}
//Support GetFeatureInfo - this Version (works great with only 1 layer)
// map.events.register('click', map, function (e) {
// //document.getElementById('map').style.cursor = 'crosshair';
// OpenLayers.Util.getElement('nodeList').innerHTML = "Einen Moment
bitte ...";
// var url = seis.getFullRequestString({
// REQUEST: "GetFeatureInfo",
// EXCEPTIONS: "application/vnd.ogc.se_xml",
// BBOX: seis.map.getExtent().toBBOX(),
// X: e.xy.x,
// Y: e.xy.y,
// INFO_FORMAT: 'text/html',
// QUERY_LAYERS: seis.params.LAYERS,
// WIDTH: seis.map.size.w,
// HEIGHT: seis.map.size.h});
// OpenLayers.loadURL(url, '', this, setHTML);
window.open(url);
// OpenLayers.Event.stop(e);
// });
// function setHTML(response) {
// OpenLayers.Util.getElement('nodeList').innerHTML =
response.responseText;}
_______________________________________________
Users mailing list
http://openlayers.org/mailman/listinfo/users
Nina Helle-Mildt
2008-11-13 11:20:19 UTC
Permalink
Hi there,

just in case of interest - that's the way I succeeded to query different
WMS in my application. There is just one restraint: The last response
(GetFeatureInfo) will overwrite earlier ones. (In my case that doesn't
matter ...)

Regards
Nina

//Support GetFeatureInfo querying different WMS

var format = 'text/html';
//var format = 'text/plain';
var datalist = new Array(seis_ger, seis);

map.events.register('click', map, function (e) {
OpenLayers.Util.getElement('nodeList').innerHTML = " ";

for (var i = 0; i < datalist.length; i++) {
var dlist = datalist[i];
url = dlist.getFullRequestString({
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: dlist.map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: format,
QUERY_LAYERS: dlist.params.LAYERS,
WIDTH: dlist.map.size.w,
HEIGHT: dlist.map.size.h});

OpenLayers.loadURL(url, '', this, setHTML);
OpenLayers.Event.stop(e);
}
});

function setHTML(response) {
var res = response.responseText;
if (res.length > 1 && res.indexOf('no results') == -1) {
OpenLayers.Util.getElement('nodeList').innerHTML = res;
}
}

Continue reading on narkive:
Loading...