[OpenLayers-Users] zoomToExtent and ExtJS Grid
Bart van den Eijnden (OSGIS)
bartvde at osgis.nl
Sun Sep 6 14:18:31 EDT 2009
Hi,
try using OpenLayers.Bounds.fromString. It takes a string as an argument
and returns a bounds.
Best regards,
Bart
AlessioDL wrote:
> 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
>
--
Bart van den Eijnden
OSGIS, Open Source GIS
bartvde at osgis.nl
http://www.osgis.nl
More information about the Users
mailing list