3

I've got an OpenLayers web application 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 and 1 for the world, 2-4 for Europe, 5-7 for Spain and so on. Then, when I am zooming 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 implement it myself?

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

2 Answers 2

1

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.

2
  • 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. Commented Nov 12, 2012 at 19:33
  • Yes, I agree. There are several open-source tile caches like GeoWebCache or TileCache.
    – webrian
    Commented Nov 13, 2012 at 7:29
0

@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...

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.