Hi all,
I'm at my wits end here trying to get this GetFeatureInfo request to work.
I'm fairly new at this but i've followed all the instructions to a T as far
as I can tell. I'm using openlayers with Geoserver 1.6RC2. I have a
shapefile of tract polygons. I just wanted the user to be able to click and
get the basic information. Just like it does in the Map Preview in the
administration section, which it works perfectly there.
It says Loading... please wait for a few seconds when i click a feature, and
then shows no results. I appreciate any help I can get
Here is the code that I have for the page.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="../HelpSiteStyleSheet.css">
<style type="text/css">
#map {
allign: Center
width: 80%;
height: 550px;
border: 2px solid gray;
}
</style>
<script language="javascript" type="text/javascript"
src="firebug/firebug.js"></script>
<script
src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js’></script>
<script
src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAPYUJlT7BwXjNXNlvzvrMahTTsSRCFcrgzIaqTplE7rb_a2a_0xRMsyD_Wq8bBmEKq7xojuvY-WeTxg’></script>
<script
src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script>
<script src="openlayers/OpenLayers.js"></script>
<script type="text/javascript">
// make map available for easy debugging
var map;
function setHTML(response) {
OpenLayers.Util.getElement('nodelist').innerHTML =
response.responseText;
};
// avoid pink tiles
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
OpenLayers.Util.onImageLoadErrorColor = "transparent";
function init(){
var options = {
projection: "EPSG:900913",
units: "m",
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
20037508.34, 20037508.34)
};
map = new OpenLayers.Map('map', options);
// create Google Mercator layers
var groads = new OpenLayers.Layer.Google(
"Google Streets",
{'type': G_NORMAL_MAP, 'sphericalMercator': true}
);
var gsathyb = new OpenLayers.Layer.Google(
"Google Hybrid",
{type: G_HYBRID_MAP, 'sphericalMercator': true}
);
var vehyb = new OpenLayers.Layer.VirtualEarth(
"Virtual Earth Hybrid",
{'type': VEMapStyle.Hybrid, 'sphericalMercator': true}
);
var gsat = new OpenLayers.Layer.Google(
"Google Sattelite",
{type: G_SATELLITE_MAP, 'sphericalMercator': true}
);
// create Virtual Earth layers
var veaer = new OpenLayers.Layer.VirtualEarth(
"Virtual Earth Aerial",
{'type': VEMapStyle.Aerial, 'sphericalMercator': true}
);
var yahoosat = new OpenLayers.Layer.Yahoo(
"Yahoo Sattelite",
{'type': YAHOO_MAP_SAT, 'sphericalMercator': true}
);
var ActiveTract = new OpenLayers.Layer.WMS(
"Active Tracts",
"http://WPC-4193.cnsl.com:8080/geoserver/wms",
{
layers: 'topp:TractActive',
styles: '',
srs: 'EPSG:4326',
format: 'image/gif',
tiled: 'true',
TRANSPARENT: "TRUE"
},
{
'reproject': true, 'opacity': 0.0,
'isBaseLayer': false,'wrapDateLine': true
}
);
var wms = new OpenLayers.Layer.WMS(
"TOPP States",
"http://WPC-4193.cnsl.com:8080/geoserver/wms?",
{
layers: 'topp:states',
styles: '',
srs: 'EPSG:4326',
format: 'image/png',
tiled: 'true',
tilesOrigin : "143.60260815000004,-43.851764249999995",
transparent: true
},
{
'reproject': false, 'opacity': 0.75,
'isBaseLayer': false,'wrapDateLine': true
}
);
bounds = new OpenLayers.Bounds();
bounds.extend(new OpenLayers.LonLat(-8951082,5033225));
bounds.extend(new OpenLayers.LonLat(-8977987,4615574));
// add the created layers to the map (if you want custom layers
to show up they must be here as well)
map.addLayers([groads, gsathyb, vehyb, gsat, veaer, yahoosat,
wms, ActiveTract]);
var control = new OpenLayers.Control.LayerSwitcher();
map.addControl(control);
map.addControl(new OpenLayers.Control.MouseDefaults());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({element:
$('position')}));
map.zoomToExtent(bounds);
control.maximizeControl();
// support GetFeatureInfo
map.events.register('click', map, function (e) {
OpenLayers.Util.getElement('nodelist').innerHTML =
"Loading... please wait...";
var url = ActiveTract.getFullRequestString(
{
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: ActiveTract.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: 'text/html',
QUERY_LAYERS: ActiveTract.params.LAYERS,
srs: 'EPSG:4326',
styles: '',
WIDTH: ActiveTract.map.size.w,
HEIGHT: ActiveTract.map.size.h
},
"http://WPC-4193.cnsl.com:8080/geoserver/wms"
);
OpenLayers.loadURL(url, '', this, setHTML);
OpenLayers.Event.stop(e);
});
}
</script>
</head>
<body onload="init()">
<style="text-align: center">
../index.htm
../_borders/resize.jpg
<h1 style="text-align: center"> QUICK VIEW MAP</h1>
<h2>Google Maps, Yahoo! Maps and Virtual Earth plus GeoServer, Powered
by OpenLayers</h5>
<div id="map"></div>
<div id="position"></div>
<div id="scale"></div>
</body>
<div id="nodelist">Click on the map to get feature infos</div>
</html>
Thanks,
JM
--
View this message in context: http://www.nabble.com/GetFeatureInfo-Help-tp14673416p14673416.html
Sent from the GeoServer - User mailing list archive at Nabble.com.