[OpenLayers-Users] Nodelist Info / GetFeatureInfo not working
boxplot
tolpxob at googlemail.com
Sat May 8 13:21:37 EDT 2010
Hi,
I use the following example of geolayers to test GetFeatureInfo (it works, so this can be no proxy-issue, also OpenLayers and GeoServer run on the same server). But when I copy the (what I think) relevant parts into my own code, it is not working anymore (after clicking on the line the text switches from "Click on the map to get feature info" to "Loading... please wait..." and that's it). So it would be great to know what the minimum requirements for this method are? And if it is possible to limit the output to some properties of the layer?
Maybe the problem is the line
> QUERY_LAYERS: map.layers[0].params.LAYERS,
because I have more than one layer in my own map?
Thanks for any help!
Pascal
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <title>OpenLayers map preview</title>
> <!-- Import OL CSS, auto import does not work with our minified OL.js build -->
> <link rel="stylesheet" type="text/css" href="http://myownhomepage.xyz:80/geoserver/openlayers/theme/default/style.css"/>
> <!-- Basic CSS definitions -->
> <style type="text/css">
> /* The map and the location bar */
> ########### (... deleted for size reasons) ###########
>
> /* Styles used by the default GetFeatureInfo output, added to make IE happy */
> table.featureInfo, table.featureInfo td, table.featureInfo th {
> border: 1px solid #ddd;
> border-collapse: collapse;
> margin: 0;
> padding: 0;
> font-size: 90%;
> padding: .2em .1em;
> }
>
> table.featureInfo th {
> padding: .2em .2em;
> text-transform: uppercase;
> font-weight: bold;
> background: #eee;
> }
>
> table.featureInfo td {
> background: #fff;
> }
>
> table.featureInfo tr.odd td {
> background: #eee;
> }
>
> table.featureInfo caption {
> text-align: left;
> font-size: 100%;
> font-weight: bold;
> text-transform: uppercase;
> padding: .2em .2em;
> }
> </style>
>
> <!-- Import OpenLayers, reduced, wms read only version -->
> <script src="http://myownhomepage.xyz:80/geoserver/openlayers/OpenLayers.js" type="text/javascript">
> </script>
> <script type="text/javascript">
> var map;
> var untiled;
> var tiled;
> var pureCoverage = false;
> // pink tile avoidance
> OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
> // make OL compute scale according to WMS spec
> OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;
>
> function init(){
> // if this is just a coverage or a group of them, disable a few items,
> // and default to jpeg format
> format = 'image/png';
>
> var bounds = new OpenLayers.Bounds(
> 12.336, 47.699,
> 12.354, 47.751
> );
>
> var options = {
> controls: [],
> maxExtent: bounds,
> maxResolution: 0.000203125,
> projection: "EPSG:4326",
> units: 'degrees'
> };
>
> map = new OpenLayers.Map('map', options);
>
> // setup tiled layer
> tiled = new OpenLayers.Layer.WMS(
> "Layer - Tiled", "http://myownhomepage.xyz:80/geoserver/wms",
> {
> width: '177',
> srs: 'EPSG:4326',
> layers: 'Workspace:Layer',
> height: '512',
> styles: '',
> format: format,
> tiled: 'true',
> tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
> },
> {
> buffer: 0,
> displayOutsideMaxExtent: true
> }
> );
>
>
> map.addLayer(tiled);
>
> // build up all controls
> map.addControl(new OpenLayers.Control.PanZoomBar({
> position: new OpenLayers.Pixel(2, 15)
> }));
> map.addControl(new OpenLayers.Control.Navigation());
> map.addControl(new OpenLayers.Control.Scale($('scale')));
> map.addControl(new OpenLayers.Control.MousePosition({element: $('location')}));
> map.zoomToExtent(bounds);
>
> // wire up the option button
> var options = document.getElementById("options");
> options.onclick = toggleControlPanel;
>
> // support GetFeatureInfo
> map.events.register('click', map, function (e) {
> document.getElementById('nodelist').innerHTML = "Loading... please wait...";
> var params = {
> 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,
> Srs: 'EPSG:4326',
> Layers: 'Workspace:Layer',
> Styles: '',
> WIDTH: map.size.w,
> HEIGHT: map.size.h,
> format: format};
> OpenLayers.loadURL("http://myownhomepage.xyz:80/geoserver/wms", params, this, setHTML, setHTML);
> OpenLayers.Event.stop(e);
> });
> }
>
> // sets the HTML provided into the nodelist element
> function setHTML(response){
> document.getElementById('nodelist').innerHTML = response.responseText;
> };
>
> ########### (... deleted for size reasons) ###########
> </script>
> </head>
> <body onload="init()">
> <div id="toolbar" style="display: none;">
> ########### (... deleted for size reasons) ###########
> </div>
> <div id="map">
> <img id="options" title="Toggle options toolbar" src="http://myownhomepage.xyz:80/geoserver/options.png"/>
> </div>
> <div id="wrapper">
>
> <div id="location">location</div>
> <div id="scale">
> </div>
> </div>
> <div id="nodelist">
> <em>Click on the map to get feature info</em>
> </div>
> </body>
>
> </html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100508/b5de9049/attachment.html
More information about the Users
mailing list