Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've god an OpenLayer web with a custom XYZ layer which downloads tiles from the server itself:

OpenLayers.Layer.MOBAC_OSMDROID_ZIP = OpenLayers.Class(
          OpenLayers.Layer.XYZ, {
              name: "tiles base",
              transitionEffect: "resize",
              sphericalMercator: true,
              url: '../map/${z}/${x}/${y}.png',
              [...]
          });

The funny thing here is that I can use MOBAC to download selected parts of OpenStreetMap and serve them from my website. So far, so good.

The problem is: obviously I do not want to download the whole world from OpenStreetMap, but only, for example, zoom levels 0 & 1 for the world, 2-4 for Europe, 5-7 for Spain and so on. Then, when I am zomming in to Spain I get the right tiles. But if I move outside Spain, I just get the damn pink "no-tile" image. I can easily remove such no-image with the .olImageLoadError CSS class... but it still does not show a map.

What I would like is: if there is no tile, use the previous tile, scaled. This way you will probably have an overview of where you are when there are no specific tiles for such level.

Any idea? Is something like this included in OpenLayers? Any idea to implemente it myself?

Since the "resize" effect does not remove the old tiles for a while, maybe keeping them "forever" would work...

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

If you want to have different zoom levels for different extents, you have to define three layers with corresponding maxExtent, minScale and maxScale.

Otherwise you need to implement a server-side solution, e.g. a small script that delivers the scaled tiles.

Anyway, I don't recommend to upscale the map tiles, since this won't look nice. It's probably better and easier to get generalized map data (e.g. from Natural Earth) and use a WMS, that provides the tiles.

share|improve this answer
    
Your second idea is probably the best for me. I have full control of the tile server. Obviously, there is a trade-off between CPU and storage, but I think I can deal with it (even more just using the http cache mechanisms). Thanks a lot. –  Javier Sedano Nov 12 '12 at 19:33
    
Yes, I agree. There are several open-source tile caches like GeoWebCache or TileCache. –  webrian Nov 13 '12 at 7:29
add comment

@Javier Sedano, this is really important point for openlayers. but there is no solution for this because of image tiles...

however i can advise you to ReadyMap OpenLayers api which can handle this problem. i have used it for a long time. when it dont have tiles on special areas, it serves you to low level tiles for viewing but with pixel degradation. you can check out it here.

pixelling

i hope it helps you...

share|improve this answer
add comment

Your Answer

 
discard

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

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