1

Upon changing the resolution of my Map's view with View.setResolution(API doc), the map zooms as expected, but the OSM layer which is included in the Map does not refresh the tiles according to the new resolution level. Manually (e.g. with the mouse wheel) zoomin in and out once shows the OSM layer as expected. How can I tell the map (or the OSM layer) to refresh? I already tried to dispatchChangeEvent() on the OSM layer but it did not change anything.

1 Answer 1

1

As far as I know OSM has predefined resolutions with every zoom level (0-28). With this solution they only have to store "only" 29 sets of tiles from the world on their servers and in return for this they don't have to deal with tile computing, which would be very resource wasting at their attendance level.

If you try to request a resolution different than the predefined value, the server won't create tiles for your needs, it will send out the tiles from the nearest zoom level and OL will display it with your preferred resolution (good chance it will be blurred).

Try to stack with View.setZoom() or map.getView().setZoom(). If you have a good reason to use only resolution values, you can request the resolution from the server at every zoom level (I used my browser's console for this). The predefined resolutions from the first five zoom levels are the following:

map.getView().setZoom(0);
undefined
map.getView().getResolution();
156543.03392804097

map.getView().setZoom(1);
undefined
map.getView().getResolution();
78271.51696402048

map.getView().setZoom(2);
undefined
map.getView().getResolution();
39135.75848201024

map.getView().setZoom(3);
undefined
map.getView().getResolution();
19567.87924100512

map.getView().setZoom(4);
undefined
map.getView().getResolution();
9783.93962050256

map.getView().setZoom(5);
undefined
map.getView().getResolution();
4891.96981025128
1
  • Ok, so a possible solution would be to find the next (or next lower) zoom level than the one I originally calculated.
    – quazgar
    Sep 7, 2014 at 17:57

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.