[OpenLayers-Users] Is there a way to get the absolute bounding box
of a feature in a layer?
cgp
carina_palanca at forcorp.com
Wed Dec 2 18:36:27 EST 2009
Please see image attached. http://n2.nabble.com/file/n4103130/feature.png
My goal is to zoom in to a feature when I click on a button.
My code would be essentially like this (assuming all required declarations
are made):
$("#zoomToFeatureButton").click(function(){
var feature_id = $("#input_feat_id").val();
var bounds = getFeatureBounds(feature_id ); //get bounds of
feature
zoomToFeature(bounds );
}
function zoomToFeature(data) {
var bounds = data.split("^"); //bounds passed in
var min_x = bounds[0];
var min_y = bounds[1];
var max_x = bounds[2];
var max_y = bounds[3];
var feature_bounds = new OpenLayers.Bounds(min_x, min_y, max_x, max_y);
map.zoomToExtent(feature_bounds,true);
}
My problem is within getFeatureBounds(feature_id ). I can't seem to find
anything that would allow me to get the bounding box of a feature. If I can
get the min x, min y, max x and max y of a feature, will that let me create
a Bounds object and use that for zooming?
Thanks.
--
View this message in context: http://n2.nabble.com/Is-there-a-way-to-get-the-absolute-bounding-box-of-a-feature-in-a-layer-tp4103130p4103130.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list