Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using this to center my points in the map screen:

var centerPoint = new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y);

what should I use to center polylines and polygons?

thanks in advance,

share|improve this question

You can use the following:


This will center your map to the center of your vector layer 1, at a zoom level 12.

share|improve this answer
thanks for the the idea, how about if I want to set the zoom according to the size of each feature? I mean I have a big polygon and a point with the same name, both features are selected but they are not zoomed proportionally to their sizes, is it possible? – Gery Feb 20 '13 at 14:49
found the solution, it was just to use and if/else with a like operator – Gery Feb 20 '13 at 18:36
up vote 1 down vote accepted


var ft = vectorLayer.features[0];
var bounds = ft.geometry.bounds;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.