[OpenLayers-Users] WFS popup alignment

Joanne Cook j.cook at oxfordarch.co.uk
Thu Dec 4 09:51:40 EST 2008


Hi List,

I have both WMS and WFS layers from a postgres table (starting with WMS but moving to WFS as you zoom in), on top of Microsoft Virtua Earth. You click the WFS points and get a framedcloud popup of the feature attribute data. This aspect works fine, but there is an issue with the alignment of the WFS points. There are some zoom levels where I can see that the WFS layer does not align correctly with the WMS, this is worse at the bottom of the map square and better towards the top. Not only that, the anchor for the popup aligns correctly with the WMS rather than the WFS. So you click on a point and the popup appears next to the correct location rather than where you have clicked.

I assume this is something to do with projections, but I'm a little stuck and would appreciate some assistance. I can't show the map itself because it isn't available to the outside world, but the salient bits of the code are here:

 var map, ve, wms, wfs, drawControls, selectControl, selectedFeature;
        function onPopupClose(evt) {
            selectControl.unselect(selectedFeature);
        }
        function onFeatureSelect(feature) {
          selectedFeature = feature;
			var projcode = selectedFeature.attributes['projcode'];
			var sitecode = selectedFeature.attributes['sitecode'];
			var projnam = selectedFeature.attributes['projnam'];
			var year = selectedFeature.attributes['year'];
            popup = new OpenLayers.Popup.FramedCloud("info", 
                                     feature.geometry.getBounds().getCenterLonLat(),
                                     null,
                                     "<div style='font-size:.8em'>Project Code: " + projcode +"<br />Site Code: " + sitecode+"<br />Project Name: " + projnam + "<br />Year: " + year + "</div>",
                                     null, true, onPopupClose);
            feature.popup = popup;
            map.addPopup(popup);
        }
        function onFeatureUnselect(feature) {
            map.removePopup(feature.popup);
            feature.popup.destroy();
            feature.popup = null;
        }    
        function init(){
            map = new OpenLayers.Map('map');
            ve = new OpenLayers.Layer.VirtualEarth( "Virtual Earth",{'type': VEMapStyle.Hybrid});
            wms = new OpenLayers.Layer.WMS("OA Sites WMS", "http://10.0.10.106/cgi-bin/mapservpostgis.cgi?",
                               {layers: 'oasites', transparent: true, format: 'image/png', buffer:0},
                                {isBaseLayer: false, reproject: true},
                                {scales: [14000000,500000]});
            wfs = new OpenLayers.Layer.WFS("OA Sites WFS", "http://10.0.10.106/cgi-bin/mapservpostgis.cgi?",
                                {typename: 'oasites', maxfeatures: 200, featureNS: 'http://mapserver.gis.umn.edu/mapserver', typename: 'ms:oasites'},
                                {scales: [500000, 10], extractAttributes: true},
                                {style: OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style['default'])});


Thanks

Jo

-----------------------------------------------------
Joanne Cook
Senior IT Support and Development
Oxford Archaeology (North)
01524 880212
http://thehumanjourney.net


------
Files attached to this email may be in ISO 26300 format (OASIS Open Document Format). If you have difficulty opening them, please visit http://iso26300.info for more information.




More information about the Users mailing list