[OpenLayers-Users] zoomToExtent and ExtJS Grid

AlessioDL alessio.dilorenzo at gmail.com
Sun Sep 6 13:36:08 EDT 2009


Hi all,

I'm having a strange issue with zoomToExtent(bounds) when the bounds values
come from and ExtJS GridPanel.

This is my code

 // create the data store
    var store = new Ext.data.JsonStore({
                url: 'resultSetJson.php',
                fields: [
                        {name: 'sent_id', type:'int'},
                        {name: 'denominazione'},
                        {name:'tempo_perc'},
                        {name:'estensionegm'}
                ]
    });

    // load data from the url ( data.php )
    store.load();

    // create the Grid
    var grid = new Ext.grid.GridPanel({
                store: store,
                columns: [
                        {id:'sent_id',header: 'ID', width: 30, sortable:
true, dataIndex: 'sent_id'},
                        {header: 'Denominazione', width: 430, sortable:
true, dataIndex: 'denominazione'},
                        {header: 'Tempo', width: 50, sortable: true,
dataIndex: 'tempo_perc'}
                        {header: 'Estensione', width: 50, sortable: true,
dataIndex: 'estensionegm'}
                ],
                stripeRows: true,
                border:false,
                height:250,
                width:500,
                autoScroll:true,

                listeners:{
                        rowclick:function(grid,rowIndex,e) {
                                //alert(rowIndex);
                               
//alert(grid.getStore().getAt(rowIndex).get('estensionegm'));

                                var sentExtent =
grid.getStore().getAt(rowIndex).get('estensionegm');
                                alert(sentExtent);
                                alert(new
OpenLayers.Bounds(sentExtent).toBBOX());
                                map.zoomToExtent(new
OpenLayers.Bounds(sentExtent));
                        }
                }

    });

    // render grid
    grid.render('sentieri-grid');


I populate my grid thanks to a postgis query that encodes the results as
Json with php. 
In the "estensionegm" column I put the geometry bbox (calculated by
postgis), then I put values in the sentExtent var (as you can see in the
code).

the sentExtent alert return the correct values, for example (in spherical
mercator):
1567540.36063275,5196100.3682006,1567671.48470329,5196716.04655338

but when I use the sentExtent var in the new
OpenLayers.Bounds(sentExtent).toBBOX(); it returns only the first value
(xmin) and three zeros:
1567540.360633,0,0,0

so, the map.zoomToExtent(new OpenLayers.Bounds(sentExtent)); can't work!

What I can do? 

Thanks, alessio
-- 
View this message in context: http://n2.nabble.com/zoomToExtent-and-ExtJS-Grid-tp3593347p3593347.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list