[OpenLayers-Users] Popup Attribute Display format

Cress B. cress.bates at co.lane.or.us
Fri Oct 23 11:42:53 EDT 2009

Hi Marc,

Thanks for your response.  Turns out the answer to my problem was pretty
simple.  I changed INFO/FORMAT to "text/html" in the getfeatureinfo
request in my script.  Also made the same change to my mapfile in the
Metadata sections for the WEB and LAYER sections.  Then figured out that
I needed to create a separate .html file that controls the format of my
popup display.  This html file is referenced in the mapfile as the
TEMPLATE parameter:
DATA         'HomeTaxlots2'
    STATUS       OFF
    TYPE         POLYGON
    STATUS       ON
 DUMP         TRUE
 TEMPLATE     /ms4w/apache/htdocs/taxlot_poly_attr3.html
and here's my "taxlot_poly_attr3.html" that formats the popup fields:
<table style='font-size:.8em'>
<tr><td width="12">Map:</td><td width="100">[MAPNUMBER]</td></tr>



From: Marc Jansen-2 (via Nabble)
[mailto:ml-user+161378-1298197223 at n2.nabble.com] 
Sent: Saturday, October 10, 2009 4:52 AM
To: BATES Cress A (Lane Cty)
Subject: Re: [OpenLayers-Users] Popup Attribute Display format

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. 


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
> the popup to work using the getfeatureinfo method.  I can control
> items appear in the popup with "wms_include_items" in the Metadata
> of the Layer in my mapfile.  But I'm having trouble figuring out how
> 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
> Any help would be GREATLY appreciated, including an example if
> code snip: 
>     var createPopup = function(response) { 
> var lonlat = map.getLonLatFromViewPortPx(this.xy); 
>         var popup = new OpenLayers.Popup.FramedCloud( 
>                  "info",lonlat, null,
> 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}, 
>             OpenLayers.loadURL(url, '',e, createPopup); 
>             OpenLayers.Event.stop(e); 
> Thanks, 
> Cress 

Users mailing list 
[hidden email]


View message @
To unsubscribe from Popup Attribute Display format, click here
< (link removed) 
AY28ubGFuZS5vci51c3wzNzk1NTc4fC03MDgxNzUwNjg=> . 

View this message in context: http://n2.nabble.com/Popup-Attribute-Display-format-tp3795578p3879484.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091023/9d4f78a1/attachment.html

More information about the Users mailing list