[OpenLayers-Users] Popup Attribute Display format

Cress B. cress.bates at co.lane.or.us
Fri Oct 9 11:58:01 EDT 2009


Hi all,

I'm now using a WMS mapfile to display tax lot polygons and want to have a
popup display when the user clicks on the tax lot.  I've successfully gotten
the popup to work using the getfeatureinfo method.  I can control which
items appear in the popup with "wms_include_items" in the Metadata portion
of the Layer in my mapfile.  But I'm having trouble figuring out how to
format the display of those items in the popup.  Currently the popup has the
attrubutes basically all run together as one long string.  I would like to
show each attribute name and value on a separate line within the popup.

Any help would be GREATLY appreciated, including an example if possible.

code snip:

    var createPopup = function(response) { 
		var lonlat = map.getLonLatFromViewPortPx(this.xy); 
        var popup = new OpenLayers.Popup.FramedCloud( 
                 "info",lonlat, null, response.responseText,null,true); 
		popup.setBackgroundColor("#c1cdc1");
		popup.setOpacity(0.7);
        map.addPopup(popup, true /* exclusive */);

		function onFeatureUnselect(event) { 
             var feature = event.feature; 
             if(feature.popup) { 
                 map.removePopup(feature.popup); 
                 feature.popup.destroy(); 
                 delete feature.popup; 
             } 
		}
    }; 

    map.events.register('click', map, function (e) {
            var url =  wms.getFullRequestString({
                            REQUEST: "GetFeatureInfo",
                            EXCEPTIONS: "application/vnd.ogc.se_xml",
                            BBOX: wms.map.getExtent().toBBOX(),
                            X: e.xy.x,
                            Y: e.xy.y,
                            INFO_FORMAT: 'text/plain',
                            QUERY_LAYERS: 'taxlots',
                            WIDTH: wms.map.size.w,
                            HEIGHT: wms.map.size.h},
                           
"http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apache/htdocs/homeinfo_wms_v02.map&SERVICE=WMS&VERSION=1.1.1");

            OpenLayers.loadURL(url, '',e, createPopup);
            OpenLayers.Event.stop(e);

Thanks,

Cress
-- 
View this message in context: http://n2.nabble.com/Popup-Attribute-Display-format-tp3795578p3795578.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list