i have made a wms layers in openlayers consuming cached tiles generatred by tile cache , in the generation step i have used this configuration :

[vmap0] type=WMS url=http://localhost/cgi-bin/mapserv?map=maps/poimanager/nav 2tiles.map layers=nav_map bbox=-855822.40976158,3975513.7271299,-847686.6435646,3976531.2950689 levels=20

concerning the map in openlayers i have defined the resolutions in map instance options:

      var options = {
    maxExtent: new OpenLayers.Bounds(-2015494, 2445884, 48919, 4383204),
    projection: "EPSG:900913",
    displayProjection: new OpenLayers.Projection("EPSG:4326"),
    units: 'm',
    numZoomLevels: 20,
resolutions :[3.9725420883691527, 1.9862710441845763, 0.99313552209228817, 0.49656776104614408, 0.24828388052307204, 0.12414194026153602, 0.062070970130768011, 0.031035485065384005, 0.015517742532692003, 0.0077588712663460013, 0.0038794356331730007, 0.0019397178165865003, 0.00096985890829325017, 0.00048492945414662508, 0.00024246472707331254, 0.00012123236353665627, 6.0616181768328135e-05, 3.0308090884164068e-05, 1.5154045442082034e-05, 7.5770227210410169e-06]

            var map = new OpenLayers.Map('map', options);

but i still get nothing just when i try to view the images using firebug it gimme this error :

"An error occurred: Lower left corner (-851825.191138, 3976933.501194) is outside layer bounds [-855822.40976158006, 3975513.7271298999, -847686.64356460003, 3976531.2950689001]. To remove this condition, set extent_type=loose in your configuration."

can you help me resolve this error :)

thanks in advance :)

3 Answers 3


Did you try what the error message suggested and set the extent_type to loose?

url=http://localhost/cgi-bin/mapserv?map=maps/poimanager/nav 2tiles.map

I've also had to update one of the Python files in TileCache to avoid the "too far from tile corner" errors on a couple of occasions using the patch outlined here.

If neither of these work then there is a problem with your bbox and the resolutions you have in OpenLayers. I'd set the maxExtent in OpenLayers to the extent of the world in EPSG:900913 and remove your resolutions parameter from your OpenLayers layer setup.

  • yes i i've tried it but :( without a result i am getting another error "An error occurred: Current x value -851676.965662 is too far from tile corner x -851677.062092 " can you advice me the manner to teste in tile cache is to generate one zoom on little extente or multiple zoom ??
    – geogeek
    May 16, 2011 at 15:22
  • Solved, i have patched the python script and i have matched the extent of the files :) thanks a lot :D , you have saved me
    – geogeek
    May 17, 2011 at 9:25
  • Sorry , i have got the same probleme again but this time i have tried what @geographika adviced but without a result, this is my openlayers code :
    – geogeek
    May 19, 2011 at 13:48
  • var options = {maxExtent: new OpenLayers.Bounds(-2015494,2445884,48919,4383204),projection: "EPSG:900913",displayProjection: new OpenLayers.Projection("EPSG:4326"),units: 'm', numZoomLevels: 20 ,resolutions :[156543..8586] }; var map = new OpenLayers.Map('map', options); // tilecache layer googleLayer = new OpenLayers.Layer.WMS("Maroc", 'localhost/cgi-bin/tilecache.cgi?', { layers: 'vmap0', format: 'image/png' }, options);
    – geogeek
    May 19, 2011 at 13:55
  • this is my tile cache config # [vmap0] # type=WMS # url=localhost/cgi-bin/mapserv?map=maps/poimanager/… # layers=navcities # bbox=-2015494,2445884,48919,4383204 # levels=20 # extent_type=loose # spherical_mercator=true # resolutions=156543.03390000001,78271.516950000005,39135.758475000002,19567.8
    – geogeek
    May 19, 2011 at 13:56

It is not enough to make the extents match. Setting the service bbox value and the OL map maxExtent to be the same value will not result in layers begin placed in the correct location. You must be very specific about the extent you choose. I've posted a tool here which provides an extent which corresponds to a tile in the web mercator projection.

For all of North America:


For D.C. area:


Without using these extents I find that the TileCache WMS layers do not overlap with the same layer accessed directly (same WMS service without using TileCache).

An alternative may be possible to get this same result by providing tileOrigin, tileOriginCorner and tileSize when constructing the WMS layer. This approach will also require calculating the tileOrigin.

  • From tilecache docs: The most important thing to do is to ensure that the OpenLayers Layer has the same resolutions and bounding box as your TileCache layer. You can define the resolutions in OpenLayers via the ‘resolutions’ option or the ‘maxResolution’ option on the layer. The maxExtent should be defined to match the bbox parameter of the TileCache layer.
    – ca0v
    Jul 27, 2012 at 16:29

Hopefully it works :) just by setting srs to 900913

[vmap0] type=WMS url=http://localhost/cgi-bin/mapserv?map=maps/poimanager/navcities2tiles.map layers=navcities bbox=-2015494,2445884,48919,4383204 levels=20 extent_type=loose srs=EPSG:900913

thanks a lot geographika , your help is very interresting

Your Answer

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

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