[OpenLayers-Users] Popup Attribute Display format

Marc Jansen jansen at terrestris.de
Sat Oct 10 07:51:51 EDT 2009


Hi Cress,

Play around with the INFO_FORMAT-parameter of the 
getFeatureInfo-Request. E.g. "application/vnd.ogc.gml" would perhaps be 
better suited.

INFO_FORMAT: 'application/vnd.ogc.gml',

Afterwards look at the response and try to parse/read the servers' 
answer using a proper OpenLayers.Format. With the parsed info you can 
build any HTML you want and insert it into the popup.

Regards,
Marc



Cress B. schrieb:
> 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
>   




More information about the Users mailing list