[OpenLayers-Users] GetFeatureInfo
Nina Helle-Mildt
helle at sdac.hannover.bgr.de
Fri Oct 31 06:59:56 EDT 2008
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;}
More information about the Users
mailing list