[Tilecache] OpenLayers, Tilecache and Custom Map using ImageLayer

Nathan Boettcher NathanB at lawtonprinting.com
Thu May 22 19:53:18 EDT 2008


Thanks for the quick response Chris.  I won't sugar coat it, I totally
missed that line.

Being totally new to this stuff, I'm not sure what the maxresolutions
translates to (highest zoom level?) nor am I sure what to set the maxExtent
to (5083?).  What are normal resolutions and how did you come up with them?
For maxExtent, you said to set it to the same as the bounding box...but as a
string, or as a single value for the width/height?

I apologize for my lack of understanding.  This stuff is really interesting
but I am really new to it and do not have a mapping background to start
with.

Thanks,

-Nathan

-----Original Message-----
From: Christopher Schmidt [mailto:crschmidt at metacarta.com] 
Sent: Thursday, May 22, 2008 4:25 PM
To: Nathan Boettcher
Cc: tilecache at openlayers.org
Subject: Re: [Tilecache] OpenLayers, Tilecache and Custom Map using
ImageLayer

On Thu, May 22, 2008 at 04:10:02PM -0700, Nathan Boettcher wrote:
> Hi All,
> 
>  
> 
> I toyed with it some more and went with the ImageLayer config option as
> someone suggested rather than using the gdal2tiles tool and trying to use
> the output.  So far it works, but I have a bit of a snag.  It only shows
> half the map!  Basically, using OpenLayers if I zoom all the way out at 0
> magnification I can see a single tile with the entire map (and a little
bit
> of black).  Once I zoom in I only get the bottom half of the map.  I am
> totally clueless as to why Tilecache is only generating and showing me
tiles
> for the lower half of the map.  Anyone got any ideas?  Is it OpenLayers
> somehow?  Below is my config and OpenLayers code:
> 
>  
> 
> Tilecache.cfg
> 
> -------------------
> 
> [tilecache_options]
> 
> path=G:/mapserver/
> 
>  
> 
> [cache]
> 
> type=Disk
> 
> base=G://mapserver/cache
> 
>  
> 
> [test]
> 
> type=ImageLayer
> 
> file=G:/mapserver/test.jpg
> 
> bbox=0,0,4000,5038
> 
> filebounds=0,0,4000,5038
> 
> maxresolution=16
> 
>  
> 
>  
> 
> OpenLayers:
> 
> --------------------
> 
>     <script src="http://openlayers.org/api/OpenLayers.js"></script>
> 
>     <script type="text/javascript">
> 
>         <!--
> 
>         var map, layer;
> 
>                         
> 
>         OpenLayers.Layer.TMS.prototype.getURL = function ( bounds ) {
> 
>             bounds=this.adjustBounds(bounds);
> 
>             var res=this.map.getResolution();
> 
>             var
> x=Math.round((bounds.left-this.tileOrigin.lon)/(res*this.tileSize.w));
> 
>             var
> y=Math.round((bounds.bottom-this.tileOrigin.lat)/(res*this.tileSize.h));
> 
>             var z=this.map.getZoom();
> 
>             var
>
path=/*this.serviceVersion+"/"+*/this.layername+"/"+z+"/"+x+"/"+y+"."+this.t
> ype;
> 
>             var url=this.url;
> 
>             if(url instanceof Array)
> 
>             {
> 
>                         url=this.selectUrl(path,url);
> 
>             }
> 
>             return url+path;
> 
>             };
> 
>  
> 
>         function init(){
> 
>             map = new OpenLayers.Map('map');
> 
>             layer = new OpenLayers.Layer.TMS("Test TMS",
> "http://devmaps/tilecache.py/", {layername: 'test',
> type:'png',},{maxResolution: 16});

As it says in the 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."

-- http://tilecache.org/readme.html#using-tilecache-with-openlayers

You'll need to set maxExtent next to maxResolution.

Also, the , after 'png' ill break IE.

-- Chris





More information about the Tilecache mailing list