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

Greg Donald gdonald at gmail.com
Tue Dec 9 13:46:35 EST 2008


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 ],

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/



More information about the Users mailing list