0

I have number of polygons on my map, how can i center the map and set zoom so all fits in the map,

I managed to get the center of each polygon and put a marker on the center using getExtent() would it be the same for the map?

heres my code https://codepen.io/anon/pen/bqyqog?editors=1010

1

As answered here: https://stackoverflow.com/questions/34041570/open-layers-3-center-the-map-based-on-extent-on-vector-layer#34042795, you can add this to your JS code:

map.getView().fit(source.getExtent(), map.getSize());

J.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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