I know that ol3 view accepts center and zoom parameters to properly position the view. Is there a way to initialy render map that fits to provided extent [xmin,ymin,xmax,ymax]?

If no how to calculate proper zoom level that would fit to provided extent?

I know that there is fit method defined in view but that would require the map to be rendered and then zoomed.

  • Hey, did you find ? – So4ne Jan 10 '17 at 9:00
  • No. I ended up listening to map being rendered and then fitting to bounds. Something like this map.getView().fit(bounds, map.getSize()); – gisit Jan 11 '17 at 10:12
  • I did the same. I was afraid to see the map then the extent, but actually you can't see the transition so it's cool. Thanks again – So4ne Jan 11 '17 at 10:27

Your Answer

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

Browse other questions tagged or ask your own question.