[Users] control which fields are displayed in my Geoext popups

Hugo hfpmartins at gmail.com
Thu Jul 21 13:19:06 CEST 2011


Hi Robert,

What you can do in fact is:

- Make a geoserver template that will return your data in JSON format
- Then, process the data as you wish on the client side (this is, using
GeoExt)

Below you can find an example of content.ftl that is returning the data in
JSON format.

[{
<#assign i = 0 />
<#list type.attributes as attribute>
<#if (i >= 0) && (!attribute.isGeometry)>
"${attribute.name}":
<#list features as feature>
<#assign k = 0 />
<#list feature.attributes as attribute>
<#if (k = i) && (!attribute.isGeometry)>
"${attribute.value}"
</#if>
<#assign k = k+1 />
</#list>
<#if attribute_has_next>
,
</#if>
</#list>
</#if>
<#assign i = i+1 />
</#list>
}]

hope this helps.
Cheers,

Hugo

On Thu, Jul 21, 2011 at 12:15 PM, Robert Buckley
<robertdbuckley at yahoo.com>wrote:

> Hi,
>
> Standard format... text/html as defined in the Parameter tab in Firebug.
>
> I have read that if the format is changed, then the attributes can be
> manipulated ie fields can be left out. I haven´t seen any code fór it
> though.
>
> I have tried with the content.ftl file in the geoserver workspaces, but the
> results are pretty grim! I would rather do it in javascript so that
> everything is kept in my app and not spread around different applications.
>
> yours,
>
> Rob
>
>
>
> ------------------------------
> *Von:* "dan at inlet.geol.sc.edu" <dan at inlet.geol.sc.edu>
> *An:* Robert Buckley <robertdbuckley at yahoo.com>
> *CC:* users at geoext.org
> *Gesendet:* Donnerstag, den 21. Juli 2011, 12:24:24 Uhr
> *Betreff:* Re: [Users] control which fields are displayed in my Geoext
> popups
>
> What is the format of the data coming back from the WMSGetFeatureInfo?
>
> > Hi,
> >
> > I would like to do the following and after several hours of trying and
> > googling
> > will have to admit that I haven´t got far.
> >
> > I want to ...
> >
> > 1. Restrict the fields displayed in my popup window so that I can control
> > which
> > fields are displayed. I don´t want to show fid, objectid etc
> >
> > 2. Ideally I would like to use the accordion layout for when there is
> more
> > than
> > one queryable layer, but I can´t find any code to implement this. I have
> > seen it
> > on Bryan Mcbrides explorer, but apart from that can´t find any
> > documentation.
> >
> > currently I have a popup designed like this...
> >
> >
> > // create the popup
> > var featureInfo = new OpenLayers.Control.WMSGetFeatureInfo({
> > queryVisible: true,
> > highlightOnly: true,
> > maxFeatures: 5,
> > layers: [layer_wea_wms,EnMap_SG_WEA_f]
> > });
> >
> > featureInfo.events.on({
> >    getfeatureinfo: function(e) {
> >        new GeoExt.Popup({
> >            title: "Position:
> > "+mappanel.map.getLonLatFromPixel(e.xy).transform(epsg900913, epsg4326),
> >            width: 400,
> > autoHeight: true,
> > layout: 'accordion',
> > bodyStyle: 'background-color:#FFF;,font-size:14px;',
> >            autoScroll: true,
> >            maximizable: true,
> >            map: mappanel.map,
> >            lonlat: mappanel.map.getLonLatFromPixel(e.xy),
> >            html:'<p style="font-size:10px;">Attributen</p><br>'+e.text,
> > unpinnable:true,
> > anchored: true,
> > shadow: true,
> > listeners: {
> >                    close: function() {
> >                        // closing a popup destroys it, but our reference
> > is
> > truthy
> >                        popup = null;
> >                    }
> > }
> >        }).show();
> >    }
> > });
> >
> > map.addControl(featureInfo);
> > featureInfo.activate();
> >
> >
> >
> >
> > thanks for any help_______________________________________________
> > Users mailing list
> > Users at geoext.org
> > http://www.geoext.org/cgi-bin/mailman/listinfo/users
> >
>
>
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>
>


-- 
Hugo Martins
LabNT - ISEGI UNL
Campus de Campolide
1070-312 Lisboa
N 38°43'56.84", W 9°9'35.74"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110721/a77b2d20/attachment-0001.htm 


More information about the Users mailing list