[OpenLayers-Users] show wfs attributes in popup

Maria Panagou snowdrop at ath.forthnet.gr
Mon Feb 18 03:56:34 EST 2008


hi all, i'm trying trying to display a popop on hover over my wfs layer with
some wfs attributes but i'm stuck....the problem seems to be the anchoring
of the popup because i get a message in firebug for Anchored.js stating
"this.anchor.size has no properties". my wfs layer is a point layer and i
use the following code:

 var quakes_wfs = new OpenLayers.Layer.WFS( "Óçìáíôéêïß Óåéóìïß", 
                       "http://gaia.dbnet.ece.ntua.gr/cgi-bin/mapserv.exe?", 
                        {map: '../htdocs/mpanagou/Quakes.map', 
                          typename: 'Quakes'},
                          {extractAttributes: true, displayInLayerSwitcher:
false, style: OpenLayers.Util.extend({},
OpenLayers.Feature.Vector.style['default'])});

var nomoi = new OpenLayers.Layer.WMS( "ÄéïéêçôéêÜ üñéá", 
                       "http://gaia.dbnet.ece.ntua.gr/cgi-bin/mapserv.exe?", 
                        {map: '../htdocs/mpanagou/pref_shp.map', 
                          layers: 'nomoi',
						  transparent: true},
                          {isBaseLayer:true, reproject: true,
resolutions:res}); 
 
map.addLayers([quakes_wfs, nomoi]);

 drawControls = {
              selectQuake: new OpenLayers.Control.SelectFeature(quakes_wfs,
{hover:true,callbacks: {'over':feature_info_hover,
'out':feature_info_hide}})
			};

for(var key in drawControls) {
                map.addControl(drawControls[key]);
            }
drawControls.selectQuake.activate();
		
map.setCenter(extent.getCenterLonLat,0);
			
function toggleControl(element) {
            for(key in drawControls) {
                var control = drawControls[key];
                if(element.value == key && element.checked) {
                    control.activate();
                } else {
                    control.deactivate();
                }
            }
        }
        var displayedFeature = null;
		
function feature_info_hover(feature) {
            if (displayedFeature != feature &&
               (!feature.layer.selectedFeatures.length ||
               (feature.layer.selectedFeatures[0] == feature))) {
            feature_info(feature);
            displayedFeature = feature;
           }
        }	 
		function feature_info(feature) {
            selectedFeature = feature;
			
			//popup = feature.createPopup(false);
			
popup = new OpenLayers.Popup.Anchored("Info", 
			feature.geometry.getBounds().getCenterLonLat(),
			new OpenLayers.Size(250,75),
            "ö<sup>ï</sup>N: "+ feature.attributes.late + ", ë<sup>ï</sup>E:
"+ feature.attributes.lone,
			true);
            feature.popup = popup;
            map.addPopup(popup);
        }

maybe I should access the geometry of the point in another way instead of
"feature.geometry.getBounds().getCenterLonLat(),"

I've also tried to create the popup using

popup = feature.createPopup(false);
popup.setSize=....
popup.setContentHTML=

but then I get a message in firebug saying "popup has no properties" when I
try setting the size e.t.c

Thanks for your help
-- 
View this message in context: http://www.nabble.com/show-wfs-attributes-in-popup-tp15540822p15540822.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list