I am trying to render WMS layer on Google Maps and its working fine except getfeatureinfo event. When I open Geoserver and try to click on WMS featues I can get the feature info. But in my page I can see empty popup. I think the problem is with Google Maps Projection.
Code:
function init(){
var gmap = new OpenLayers.Layer.Google("Google Streets", {
visibility: false});
var options = {
controls : [],
units : "m",
numZoomLevels : 22,
maxResolution : 156543.0339,
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
maxExtent : new OpenLayers.Bounds(-20037508.34, -20037508.34,
20037508.34, 20037508.34)
};
var map = new OpenLayers.Map('map', options);
var layer1 = new OpenLayers.Layer.WMS("Layer1 - Tiled",
"http://localhost:8090/geoserver/Layers/wms", {
layers : "Layer1",
transparent : "true",
format : "image/png",
srs : 'EPSG:4326',
zoomOffset : 3,
}, {
isBaseLayer : false
});
map.addLayer(gmap);
map.addLayer(layer1);
info = new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://localhost:8090/geoserver/Layers/wms',
title: 'Identify features by clicking',
layers: [layer1],
infoFormat: 'text/html',
queryVisible: true,
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();
map.setCenter(new OpenLayers.LonLat(-104.949, 40.924).transform(
new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()),5);
map.addControl(new OpenLayers.Control.Navigation());
}
<body onload="init()">
<div style="visibility: visible; height: 100%;" id="map"></div>
</body>
Is there any way to getfeatureinfo in case of google maps (EPSG:900913) and WMS layer (EPSG:4326)? Do I need to change my code? Please share your valuable thoughts.
Help would be appreciated :)
getfeatureinfo
is not able to call/get data from geoserver. – Unknown