[Users] Putting cluster attributes into a Propertygrid

Robert Buckley robertdbuckley at yahoo.com
Mon Aug 1 21:46:07 CEST 2011


Hi,

I have a property grid which I use to show attributes from vector points. 

Due to the number of points, I have changed to a cluster strategy and would now 
like to populate the grid with the feature attributes in the cluster.

I can do this in a div outside of the popup grid, but I can´t work out how to 
get the attributes into the gird.

http://maps.zgb.de/www/testing/cluster_vector.html

Below is the code for the html div which works ok, and the popup which I can´t 
get to read the cluster attributes

Any help would be great,

yours,

Rob



Here is the code for the html element which works fine in a div

function on_select_feature(event){
//Store a reference to the element
//var info_div = document.getElementById('info_div');
//info_div.innerHTML = '';
//Store the clusters
var cluster = event.feature.cluster;
//Loop through the cluster features
for(var i=0; i<cluster.length; i++){
//Update the div with the info of the photos
info_div.innerHTML += "<strong>"
+ cluster[i].attributes.bez
+ cluster[i].attributes.standort
+ cluster[i].attributes.mw_inner
+ "<br /><hr />";
}
}
function on_unselect_feature(event){
//Store a reference to the element
var info_div = document.getElementById('info_div');
//Clear out the div
info_div.innerHTML = '';
}
vector_layer.events.register('featureselected', this, on_select_feature);
vector_layer.events.register('featureunselected', this, on_unselect_feature);


// create a control for selecting features
                var select = new OpenLayers.Control.SelectFeature(vector_layer);
                mapPanel.map.addControl(select);
                select.activate();



Here is my popup...I would like the attributes to populate this!!


                // register a listener for the feature selection and unselection
                vector_layer.events.on({
                    featureselected: function(event) {

                        // create an open a popup when a feature is selected
                        popup = new GeoExt.Popup({
                            title: "Feature Attributes",
                            feature: event.feature,
                            collapsible: true,
                            layout: "fit",
height: 130,
                            width: 170,
                            border: false,
listeners: {
                                close: function() {
                                    select.unselectAll();
                                }
                            },
                            items: [
                                new Ext.grid.PropertyGrid({
                                    autoHeight: true,
                                  source: event.feature.attributes
                                })
                            ]

                        });
                        popup.show();

                        gridPanel.getSelectionModel().each(function(rec){
                        var feature = rec.get("feature");
                        
mapPanel.map.setCenter(feature.geometry.getBounds().getCenterLonLat(), 11);})
                    },
                    featureunselected: function(event) {
                        // close (and destroy) the popup when the feature is 
unselected
                        popup.destroy();
                    }
                });
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110801/9d4e6524/attachment-0001.htm 


More information about the Users mailing list