[OpenLayers-Users] Getting Started with TMS

David Ing david.ing at gmail.com
Mon Jul 5 01:57:51 EDT 2010


Hi List,

New OpenLayers user here, so please bear with me. I've searched and spent
many hours but am still stuck. I'm using the 2.9 release.

I have a set of image tiles in z/x/y directory format, i.e.root/7/0/0.png
and so on. I'm using gdal2tiles.py to take a png image of size 18432x18432
px to turn it into 8 zoom levels (0-7). Level 7 has 72 256x256 px tiles as
expected. I just want a flat pixel by pixel projection. I have the files sat
in an accessible web server i.e. no tilecache or mapserver etc, just plain
GET /0/0/0.png

My script is very simple and is copied from the TMS example (that is the
right one to use rather than ZYX etc?) plus the HTML is from the TMS
example:


map = new OpenLayers.Map( 'map', { controls: [], maxResolution: 18432/256,
maxExtent: new OpenLayers.Bounds( 0, 0, 18432, 18432 ), numZoomLevels:8, }
); layer = new OpenLayers.Layer.TMS( "TMS", "
http://192.168.10.1/simpletest1/",
{serviceVersion: '.', layername: '.', type:'png'} ); map.addLayer(layer);

map.addControl(new OpenLayers.Control.MousePosition()); map.addControl(new
OpenLayers.Control.MouseDefaults()); map.addControl(new
OpenLayers.Control.KeyboardDefaults());

if (!map.getCenter())
map.zoomToMaxExtent();


Problem 1:

My projected coordinates seem incorrect, in that I move the mouse around and
see my tiles correctly but not to the right transformation. The bottom left
corner is 0,0, but the top right corner is just reading as 10368x10368. I
was expecting 18432x18432? I have set up the maxExtent incorrectly?

Note: I did try to use a set of manual resolutions too:

resolutions: [ 1, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625, 0.0078125]

..but I get other issues, i.e. something like -80, 80?


Problem 2:

The code about asks for many extra tiles from about zoom level 2 onwards,
i.e. An extra set of tiles above and to the right. Level 3 asks for a row of
3 extra, level 4 for 7 extra and so on. I expect this is related to (1)


I'd appreciate any help. Apologies if it's something stupid.

PS Thanks for OpenLayers - loving it...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100704/84497bb0/attachment.html


More information about the Users mailing list