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
[email protected] <mailto:[email protected]>
http://www.geoext.org/cgi-bin/mailman/listinfo/users
--
Alexandre Dubé
Mapgears
www.mapgears.com <http://www.mapgears.com>
_______________________________________________
Users mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/users
_______________________________________________
Users mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/users