[OpenLayers-Users] Re: How it works WMSGetFeatureInfo??
Francesc Cañas
kikocanas at gmail.com
Fri Feb 10 07:35:45 EST 2012
With the getfeatureinfo-controls version, I get the map with the layer but
when I click to get info nothing happens.
Firebugs don't get any error and show the request. And if I open it have
the layer info that I want to display beside the map.
http://localhost:8080/geoserver/Proj_CAT/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&LAYERS=Proj_CAT%3AProjectes_UTM31&QUERY_LAYERS=Proj_CAT%3AProjectes_UTM31&STYLES=&BBOX=-3.174805%2C38.253418%2C5.174805%2C43.746582&FEATURE_COUNT=10&HEIGHT=500&WIDTH=760&FORMAT=image%2Fpng&INFO_FORMAT=text%2Fhtml&SRS=EPSG%3A4326&X=455&Y=150
I also have this version in the /www/ folder with the openlayers.js online
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
If I try to use the downloaded version at www/openlayers/lib/openlayers.js
also says that OpenLayers is not defined
The whole code is this:
<!DOCTYPE html>
<html>
<head>
<title>Prova visor auma</title>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<link rel="stylesheet" href="C:/OpenLayers-2.11/theme/default/style.css"
type="text/css">
<style type="text/css">
#map{ height: 500px;
width: 760px;
margin:20px;
}
#info {
position: absolute;
left:80%;
top:15%;
}
#info table td {
border:1px solid #ddd;
border-collapse: collapse;
margin: 0;
padding: 0;
font-size: 90%;
padding: .2em .1em;
background:#fff;
}
#info table th{
padding:.2em .2em;
text-transform: uppercase;
font-weight: bold;
background: #eee;
}
tr.odd td {
background:#eee;
}
table.featureInfo caption {
text-align:left;
font-size:100%;
font-weight:bold;
padding:.2em .2em;
}
</style>
<script defer="defer" type="text/javascript">
var map, highlightlayer;
function load(){
var options = {
controls: [new OpenLayers.Control.KeyboardDefaults(),
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.ScaleLine(),
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.OverviewMap(),
new OpenLayers.Control.MousePosition()
]
};
map = new OpenLayers.Map('map', options);
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0?",
{layers: 'basic'}
);
var Projectes_Cat = new OpenLayers.Layer.WMS(
"Projectes UTM31",
"http://localhost:8080/geoserver/Proj_CAT/wms",
{
layers: 'Proj_CAT:Projectes_UTM31',transparent:
'true',isBaseLayer:"false"
}
);
highlightLayer = new OpenLayers.Layer.Vector("Highlighted Features", {
displayInLayerSwitcher: false,
isBaseLayer: false
}
);
map.addLayers ([wms, Projectes_Cat, highlightLayer]);
map.setCenter (new OpenLayers.LonLat (1,41), 7);
infoControls = {
click: new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://localhost:8080/geoserver/Proj_CAT/wms',
title: 'Identify features by clicking',
layers: [Projectes_Cat],
queryVisible: true
}),
}
for (var i in infoControls) {
infoControls[i].events.register("getfeatureinfo", this,
showInfo);
map.addControl(infoControls[i]);
}
infoControls.click.activate();
}
function showInfo(evt) {
if (evt.features && evt.features.length) {
highlightLayer.destroyFeatures();
highlightLayer.addFeatures(evt.features);
highlightLayer.redraw();
} else {
$('responseText').innerHTML = evt.text;
}
}
</script>
</head>
<body bgcolor=#F6E3CE onload="load()">
<h1> Visor dels Projectes d'AUMA</h1>
<div id= "map"><div>
<div id="info">
<h3>Info dels Projectes</h3>
<p><small>Click sobre els punts per detalls del projecte</small></p>
<div id="responseText"></div>
</div>
</body>
</html>
I'm running out of ideas...
--
http://kikocanas.blogspot.com
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-it-works-WMSGetFeatureInfo-tp4361191p4383169.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120210/9fd412d6/attachment-0001.html
More information about the Users
mailing list