[OpenLayers-Users] how-to calculate resolutions for custom tiles

Christopher Schmidt crschmidt at metacarta.com
Tue Dec 9 14:48:59 EST 2008


On Tue, Dec 09, 2008 at 12:46:35PM -0600, Greg Donald wrote:
> How can I calculate the resolutions for my particular map tiles?
> 
> 
> I'm using this:
> 
> http://trac.openlayers.org/wiki/UsingCustomTiles
> 
> 
> My map tiles are 256x256 pixels and I need 12 zoom levels.
> 
> My top zoom level will be 1667867 pixels wide, and 403 pixels tall.
> And then for each zoom level that follows, the data height and width
> is twice the size of the zoom level before.
> 
> 
> I'm doing this
> 
>     maxExtent: new OpenLayers.Bounds( 0, 0, 1667867, 403 ),
>     restrictedExtent: new OpenLayers.Bounds( 0, 0, 1667867, 403 ),
>     numZoomLevels: 12
> 
> but things aren't coming out right.  It seems I need to provide
> explicit resolutions?
> 
> 
> So I started experimenting with values like this:
> 
>     //resolutions: [ 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 ],
>     //resolutions: [ 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.25 ],
>     //resolutions: [ 1, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625,
> 0.0078125, 0.00390625, 0.001953125, 0.0009765625 ],

I'd expect this last one to work. You could also simply set
"maxResolution": 1, and it would calculate the rest on its own. What
aspect of that isn't working for you?

-- Chris

> and some of these attempts seems to be close to what I need, but none
> are entirely correct.  I have no clue what sort of computations I
> should do to get the exact values.
> 
> 
> So, knowing how wide and tall the data is, and how compressed it is
> per zoom level, how can I calculate my resolutions?
> 
> 
> Thanks,
> 
> 
> -- 
> Greg Donald
> http://destiney.com/
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list