In this map I have added a line of code to make it zoom to the vector layer:


This zooms in to the maximum zoom at the point in the Gulf of Guinea where the equator meets the Greenwich meridian. It is not supposed to zoom here, it is should show Scotland.

I've passed the same bit of code in the console in Chrome and that works fine.
Does anyone know why it is not working properly when the page loads and does anyone know what I can do to fix it?


1 Answer 1


You don't say where the vectors are coming from but I'm guessing you are loading them from somewhere. In which case I suspect you call getDataExtent() before the layer has finished loading. You'll need to register a listener on loadend events.

using something like: layer.events.register(type, obj, listener);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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