I tried to display data with popup from Geoserver or Postgres to my map, but it dosen't work at all. Can anyone please help me? I used this code:
function Info(e)
{
if (e.features && e.features.length)
{
//console.log(e.features[0].attributes);
var popupId = e.xy.x + "," + e.xy.y;
var popup = popups[popupId];
if (!popup || !popup.map) {
popup = new OpenLayers.Popup.FramedCloud(
popupId,
map.getLonLatFromPixel(e.xy),
null,
" ",
null,
true,
function(e) {
delete popups[this.id];
this.hide();
OpenLayers.Event.stop(e);
}
);
popups[popupId] = popup;
map.addPopup(popup, true);
}
popup.setContentHTML(popup.contentHTML + "nom_user:" +e.features[0].attributes.nomservice +" region_user :"+ e.features[0].attributes.region);
popup.show();
}
selectcltr = {
click: new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://localhost/geoserver/wms',
title: 'Identify features by clicking',
layers: [ser],
queryVisible: true
}),
hover: new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://localhost/geoserver/wms',
title: 'Identify features by clicking',
layers: [ser],
hover: true,
// defining a custom format options here
formatOptions: {
typeName: 'projet',
featureNS: 'http://www.openplans.org/topp'
},
queryVisible: true
})
}
No comments:
Post a Comment