[OpenLayers-Users] Nodelist Info not working
Arnd Wippermann
arnd.wippermann at web.de
Sun Mar 9 16:55:12 EDT 2008
Hi,
when you use OpenLayers.loadURL(url, '', this, setHTML, setHTML), you have
to declare a proxy-script. loadURL uses Ajax to the get the filecontents to
display it in your page. You can use window.open(url, "GetFeatureInfo). It
opens a new window, but you need no proxy.
Mit freundlichen Grüssen
Arnd Wippermann
http://gis.ibbeck.de/
________________________________
Von: osgisfyp at gmail.com [mailto:osgisfyp at gmail.com]
Gesendet: Sonntag, 9. März 2008 19:57
An: arnd.wippermann at web.de; users at openlayers.org
Betreff: Re: [OpenLayers-Users] Nodelist Info not working
Just to clarify the "Or I have to do something other then create the
directory, put the files in it and go?" the statements I made earlier.
I used the geoserver gui to create a namespace, datastore and feature types.
All the created feature maps were available in MapPreview and all worked
fine. It just seems that when I call the layers from elsewhere then the get
feature info function stops working.
I think I'm missing a configuration step or something.
Heres the html code Im using:
geoserver/data_dir/my_project_dir/myfile.html
<?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>Pedestrian Route Finder</title>
<style type="text/css">
#map {
width: 500px;
height: 338px;
border: 1px solid black;
}
#wrapper {
width: 500px;
}
#location {
float: right;
}
</style>
<script
src="http://localhost:8080/geoserver/openlayers/OpenLayers.js"
type="text/javascript">
</script>
<script defer="defer" type="text/javascript">
var map;
var roads;
var busLines;
var luasLines;
var luasStops;
function setHTML(response) {
document.getElementById('nodelist').innerHTML =
response.responseText;
};
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;
function init(){
var bounds = new OpenLayers.Bounds(
305097.5401555448, 226935.368699667, // left, bottom
318253.033844963, 237653.04983245343 // right, top
);
var options = {
controls: [],
maxExtent: bounds,
maxResolution: 39.6698972242898,
projection: "EPSG:29900",
units: 'm'
};
map = new OpenLayers.Map('map', options);
// setup single layer
roads = new OpenLayers.Layer.WMS(
"pedestrianRouteFinder:required_roads - Untiled",
"http://localhost:8080/geoserver/wms",
{
height: '652',
width: '800',
layers: 'pedestrianRouteFinder:required_roads',
styles: 'required_roads_style',
srs: 'EPSG:29900',
format: 'image/png'
},
{isBaseLayer:true},
{singleTile: true}
);
// setup single untiled layer
busLines = new OpenLayers.Layer.WMS(
"pedestrianRouteFinder:bus_lines - Untiled",
"http://localhost:8080/geoserver/wms",
{
height: '652',
width: '800',
layers: 'pedestrianRouteFinder:bus_lines',
srs: 'EPSG:29900',
format: 'image/png',
transparent:true
},
{isBaseLayer:false, opacity:1},
{singleTile: true}
);
// setup single untiled layer
luasLines = new OpenLayers.Layer.WMS(
"pedestrianRouteFinder:luas_lines - Untiled",
"http://localhost:8080/geoserver/wms",
{
height: '652',
width: '800',
layers: 'pedestrianRouteFinder:luas_lines',
srs: 'EPSG:29900',
format: 'image/png',
transparent:true
},
{isBaseLayer:false, opacity:1},
{singleTile: true}
);
// setup single untiled layer
luasStops = new OpenLayers.Layer.WMS(
"pedestrianRouteFinder:luas_stops_snapped - Untiled",
"http://localhost:8080/geoserver/wms",
{
height: '652',
width: '800',
layers: 'pedestrianRouteFinder:luas_stops_snapped',
srs: 'EPSG:29900',
format: 'image/png',
transparent:true
},
{isBaseLayer:false, opacity:1},
{singleTile: true}
);
map.addLayers([roads, busLines, luasLines, luasStops]);
// setup controls and initial zooms
map.addControl(new OpenLayers.Control.PanZoomBar());
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({element:
$('location')}));
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToExtent(bounds);
// support GetFeatureInfo
map.events.register('click', map, function (e) {
document.getElementById('nodelist').innerHTML = "Loading...
please wait...";
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
},
"http://localhost:8080/geoserver/wms"
);
OpenLayers.loadURL(url, '', this, setHTML, setHTML);
OpenLayers.Event.stop(e);
});
}
</script>
</head>
<body onload="init()">
<div id="map"></div>
<div id="wrapper">
<div id="location"></div>
<div id="scale"></div>
</div>
<div id="nodelist">Click on the map to get feature info</div>
</body>
</html>
Thanks for the help
On 09/03/2008, Edel Banks <edel.banks at gmail.com> wrote:
---------- Forwarded message ----------
From: Edel Banks <edel.banks at gmail.com>
Date: 9 Mar 2008 18:12
Subject: Re: [OpenLayers-Users] Nodelist Info not working
To: Arnd Wippermann <arnd.wippermann at web.de>, users at openlayers.org
Arnd thanks for the reply, tried using
map.layers[2].getFullRequestString and map.layers[2].params.LAYERS as you
suggested but still get "Loading... please wait..."
I have an idea of what the problem is but not how to fix it.
I copied the source code from the openlayers tiger-ny example saved
it as my own html file in my project directory in data_dir/. My intention
was to make one change at a time to see if, when the get feature info
function would stop working to identify the issue. But the first time I
opened the file without any changes it didn't work, the "Loading... please
wait..." message was displayed when a feature is clicked.
Also, when the original tiger-ny is being called the url has a lot
of information in it:
http://localhost:8080/geoserver/wms?bbox=-74.047185,40.679648,-73.907005,40.
882078&styles=&Format=application/openlayers&request=GetMap&layers=tiger-ny&
width=431&height=550&srs=EPSG:4326
I recognise all of this information, since some of it is specified
in the html page
The url is the only thing that is different. Is their something that
needs to be added to the copied code to get the wms query working?
Or maybe my project directory structure in geoserver is incorrect?
geoserver/data_dir/project_dir/copied_tiger-ty.html
Or I have to do something other then create the directory, put the
files in it and go?
Thanks
E
On 09/03/2008, Arnd Wippermann <arnd.wippermann at web.de> wrote:
Hi,
$('layers')
map.layers[0] is not the layer of the query. Try it with
map.layers[2].
map.layers[2].getFullRequestString
map.layers[2].params.LAYERS
Mit freundlichen Grüssen
Arnd Wippermann
http://gis.ibbeck.de/
-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org
[mailto:users-bounces at openlayers.org] Im
Auftrag von osgis
Gesendet: Sonntag, 9. März 2008 15:50
An: users at openlayers.org
Betreff: Re: [OpenLayers-Users] Nodelist Info not working
Hi Chris1211,
I'm having the same problem. I've tried changing the
var url = map.layers[0].getFullRequestString(
...
QUERY_LAYERS: map.layers[0].params.LAYERS,
To:
var url = map.layers[$('layers')].getFullRequestString(
...
QUERY_LAYERS: map.layers[$('layers')].params.LAYERS,
And:
var url = map.layers[$('layer')].getFullRequestString(
...
QUERY_LAYERS: map.layers[$('layer')].params.LAYERS,
Still no joy :(
If anyone has any suggestions they'd be much appreciated.
chris1211 wrote:
>
> I am trying to get the feature info from my map that has
multi layers
> and uses the layer switcher but all i get it a please wait
the layer i
> need to quarry is the Panels layer can some one please
help. thanks
> function init(){ var bounds = new
>
OpenLayers.Bounds(-88.55546395,36.1137137,-87.98201304999999,36.5199723);
> map = new OpenLayers.Map('map', { controls: [] });
> map.addControl(new
OpenLayers.Control.PanZoomBar());
> map.addControl(new
OpenLayers.Control.MouseToolbar());
>
>
> // support GetFeatureInfo
> map.events.register('click', map, function (e) {
>
OpenLayers.Util.getElement('nodelist').innerHTML = "Loading...
> please wait...";
> 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,
> layers: 'Panels',
> styles: '',
> srs: 'EPSG:4326',
> WIDTH: map.size.w,
> HEIGHT: map.size.h},
>
>
"http://hazards.fema.gov/wmsconnector/wmsconnector/Servlet/flood"
> );
> OpenLayers.loadURL(url, '', this, setHTML,
setHTML);
> Event.stop(e);
> });
>
>
> map.addControl(new
>
OpenLayers.Control.LayerSwitcher({'div':OpenLayers.Util.getElement('la
> yerswitcher')}));
>
> var hctiger_wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
> "http://13.0.0.150:8080/geoserver/wms",
> {layers: 'District 9 Homeland'},
> {'displayInLayerSwitcher':false} );
>
> var zone_wms = new OpenLayers.Layer.WMS( "FEMA
Flood
> Zones",
>
>
"http://hazards.fema.gov/wmsconnector/wmsconnector/Servlet/flood",
> {layers: "Flood_Hazard_Zones",
transparent: "true",
> format: "image/png" });
> map.addLayer(zone_wms);
>
> var panels_wms = new OpenLayers.Layer.WMS(
"FEMA DFIRM
> Panels",
>
>
"http://hazards.fema.gov/wmsconnector/wmsconnector/Servlet/flood",
> {layers: "Panels", transparent: "true",
format:
> "image/png" });
>
> var precip_wms = new OpenLayers.Layer.WMS(
"Total Storm
> Precip",
>
>
"http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/ntp.cgi?",
> {layers: "nexrad_stormtotal_precip",
transparent:
> "true",
> format: "image/png" },
> {isBaseLayer: false, opacity: 0.5});
>
> map.addLayer(precip_wms);
>
> var nexrad_wms = new OpenLayers.Layer.WMS( "Current
Nexrad Radar",
>
>
"http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi?",
> {layers: "nexrad-n0r-m05min", transparent:
"true", format:
> "image/png" },
> {isBaseLayer: false, opacity: 0.5});
>
> map.addLayer(nexrad_wms);
>
> var polywarn_wms = new OpenLayers.Layer.WMS( "NWS
Polygon
Warnings",
>
>
"http://mesonet.agron.iastate.edu/cgi-bin/wms/us/wwa.cgi?",
> {layers: "warnings_p", transparent:
"true", format:
> "image/png" });
>
> map.addLayer(polywarn_wms);
>
> var zone = new OpenLayers.Layer.GML("Alert Zone Area",
"zone.kml",
> {format: OpenLayers.Format.KML});
> map.addLayer(zone)
>
> zone_wms.setVisibility(true);
> panels_wms.setVisibility(false);
> precip_wms.setVisibility(false);
> nexrad_wms.setVisibility(false);
> zone.setVisibility(true);
>
> map.addLayers([hctiger_wms, zone_wms,
> panels_wms,precip_wms,nexrad_wms,polywarn_wms,zone]);
> map.setCenter(new OpenLayers.LonLat(-88.328666,36.301788),
11);
>
> }
> </script>
> <title>Henry Co. EMA</title></head>
> <body onLoad="init()">
> <h3 class="style2">Henry County EMA - Map Services
Server </h3>
> <div id="layerswitcher" style="float:top; width:
20em;"></div>
> <div id="map"></div>
> <div id="docs">
> <p>Info and Desc.</p>
> </div>
> <div id="nodelist">Click on the map to get feature
infos</div>
> </body> </html>
>
--
View this message in context:
http://www.nabble.com/Nodelist-Info-not-working-tp14975579p15933774.html
Sent from the OpenLayers Users mailing list archive at
Nabble.com.
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list