Using some examples from internet, I found this code that shows WMSGetfeatureinfo
I don't know where's the problem:
Here goes my code:
<!DOCTYPE HTML>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<title>MB_OL</title>
<link rel="stylesheet" href="css/google.css">
<link rel="stylesheet" href="css/view_css.css">
<link rel="stylesheet" href="../openlayers/theme/default/style.css" type="text/css" />
<script src="../openlayers/OpenLayers.js"></script>
<script src="../openlayers/OpenLayers.debug.js"></script>
<script src="../openlayers/OpenLayers.light.debug.js"></script>
<script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>
<script>
var map;
var wgs84 = new OpenLayers.Projection("EPSG:4326");
var mercator = new OpenLayers.Projection("EPSG:900913");
var info;
var mesorregioes = new OpenLayers.Layer.WMS(
"MB:meso_domicilios - Tiled", "http://wololo.eti.br:8081/geoserver/MB/wms",
{
LAYERS: 'MB:meso_domicilios',
STYLES: 'estilo_meso',
tiled: true,
transparent: "true",
format: "image/png",
},
{
buffer: 0,
displayOutsideMaxExtent: true,
isBaseLayer: false,
yx : {mercator : true}
}
);
var gmaps = new OpenLayers.Layer.Google(
"Google Streets", // the default
{numZoomLevels: 20}
);
function init() {
map = new OpenLayers.Map('map', {
layers: [ gmaps,
mesorregioes,
],
projection: new OpenLayers.Projection(wgs84),
displayProjection: new OpenLayers.Projection(wgs84),
center: new OpenLayers.LonLat(-53.375, -29.813)
// Google.v3 uses web mercator as projection, so we have to
// transform our coordinates
.transform(wgs84, mercator),
zoom: 7,
}
);
info = new OpenLayers.Control.WMSGetFeatureInfo({
------> on firebug it shows right here: uncaught typeerror: undefined is not a function
url: 'http://wololo.eti.br:8081/geoserver/MB/wms',
title: 'Identify features by clicking',
queryVisible: true,
/*version: layers[0].params.VERSION, */
layers: 'MB:meso_domicilios',
eventListeners: {
getfeatureinfo: function(event) {
map.addPopup(new OpenLayers.Popup.FramedCloud(
"chicken",
map.getLonLatFromPixel(event.xy),
null,
event.text,
null,
true
));
}
}
});
map.addControl(info);
info.activate();
/*
function formatLonlats(lonLat) {
var lat = lonLat.lat;
var long = lonLat.lon;
return 'Coordenadas em EPSG-4326: ' + lat + ', ' + long;
};
//funcao que troca de centro para a uniao
function uniao (){
map.setCenter(
new OpenLayers.LonLat(-18.771115, -42.758789).transform(wgs84, mercator),5 )
}; */
}
</script>
<body onLoad="init()">
<div id="map" class="mapa"></div>
<div id="info_meso"></div>
</body>
</html>