[Users] help with GeoExt.grid.FeatureSelectionModel

Simon Appelt flansch at gmx.de
Thu Mar 3 15:34:57 CET 2011


Hi Mike & Alexandre,

a problem could be that everytime, you selected a feature the event gets 
triggered. I think a better way to solve this, is to add a additional 
button inc. handler, something like this maybe:
bbar: [{
                       xtype: 'tbbutton',
                       cls: 'x-btn-text-icon',
                       tooltip: "Zoom To",
                       icon: '../images/database_go.png',
                         handler: function(){
                           
gridPanel.getSelectionModel().each(function(rec)  {
                           var feature = rec.get("feature");
                           var bounds = 
feature.geometry.getBounds().toBBOX();
                           map.zoomToExtent(new 
OpenLayers.Bounds.fromString(bounds));
                       });
                 }}]

Best regards,
Simon
Am 03.03.2011 14:33, schrieb Alexandre Dube:
> Hi Mike,
>
>   Here's something you could do : listen to the vector layer 
> "featureselected" event to zoom to the extent of a feature selected 
> either from a click or row in the grid.  Here's how it should look 
> like (using the example) :
>
> vecLayer.events.on({
>     "featureselected": function(e) {
>         this.map.zoomToExtent(e.feature.geometry.getBounds());
>     },
>     "scope": vecLayer
> });
>
> If you don't want the map to zoom to the max zoomed in level when 
> selecting a Point feature, you could manage them differently by 
> detecting the type of geometry first then do a "map.setCenter(lonlat, 
> zoom)" instead and define your own zoom level when selecting points.
>
> Best regards,
>
> Alexandre
>
>
> On 11-03-02 01:44 PM, Michael Savarese wrote:
>> Greetings, I'm fairly new to GeoExt and OpenLayers and I was 
>> experimenting with the example "Grid with Features" 
>> http://api.geoext.org/1.0/examples/feature-grid.html.  I'd like to 
>> zoom or pan to a feature when the feature is clicked on the grid. 
>> I've had success with zooming to a feature with OpenLayers but I have 
>> no idea how to bind that click to an OpenLayers function. Any help in 
>> the form of an example or reference would be appreciated.
>>
>> Mike
>>
>> _______________________________________________
>> Users mailing list
>> Users at geoext.org  <mailto:Users at geoext.org>
>> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>
>
> -- 
> Alexandre Dubé
> Mapgears
> www.mapgears.com  <http://www.mapgears.com>
>
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110303/233de009/attachment.htm 


More information about the Users mailing list