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 have an app using OpenLayers and OpenStreetMap tiles. There are more zoom levels for the capital and less zoom levels for the entire country.

Let's say the user is in the capital, in his car, in traffic, with localisation active. The app is showing the map at the maximum zoom level. Them map is following him like a GPS, keeping current position in the center and marking it with a graphic symbol.

When the car reaches the bounds of the city the map have no tiles and show pink color. I need to change the zoom level before the pink missing tiles appears.

I can calculate an area inside the bounds of the capital and when the current position is inside this area the app will zoom out to the maximum zoom level available for the country. Is this the best solution?

The same problem exists when panning map with the finger. I thought to restrictExtend to the capital but then the user will be captive inside and the single chance to see the country again is to zoom out.

Do you know an algorithm or an OL function/event to help me find the best solution?

Thank you, Bogdan

share|improve this question

Your Answer


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

Browse other questions tagged or ask your own question.