Hi,

On 10/10/10 14:39, Denis Rykov wrote:
I have a vector KML layer and when I click on one of the feature I would like zoom my map to extent of this feature.
How I can get extent of feature?

var featureExtent = feature.geometry.getBounds();

should work (provided that the bounds have been calculated already). If that doesn't give you what you want or you just want to be sure that you got the 'right' bounds, use something like:

var featureExtent = feature.geometry.calculateBounds();

Then you can use:

map.zoomToExtent(featureExtent);

See the API docs for more information:
http://dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/OpenLayers/Geometry-js.html#OpenLayers.Geometry.getBounds
http://dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.zoomToExtent

Regards, Roald

_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to