Monday, 16 December 2019

tile map service - Add TMS layer to OpenLayers


I have found some examples but haven't managed yet to adapt them to my needs...


I have an image that is served as TMS (tiles already statically rendered): http://humadat.alwaysdata.net/tms/khorog/tiles


What would be the right syntax to display it in OpenLayers?


On this example: http://openlayers.org/dev/examples/tms.html It looks quite different, as if the tiles are dynamically rendered by a python script...


I tried something like this


layer = new OpenLayers.Layer.TMS( "TMS",

"http://humadat.alwaysdata.net/tms/khorog/", {layername: 'tiles', type:'jpg'}
);

But no success so far



Answer



What you serve is not a TMS service acording to Openlayers specification. They expect a service which can be questioned for tiles similar to WMS.


Unfortunately, your tiles follw the OGC naming convention, and not OSM-like. See my answer here to number the tiles correctly:


GDAL2Tiles: MapTiles from BSB/KAP are Switched


EDIT


I finally managed to load the data into QGIS using the TileLayer Plugin. That allows to switch the layer numbering between OGC and OSM.



This is my entry in the config file:


khorog  khorog  http://humadat.alwaysdata.net/tms/khorog/tiles/{z}/{x}/{y}.jpg  0   12  16  -180    -85.0   180.0   85.0

Note that tabs have to be used as delimiters. And this is the result:


enter image description here


with OSM in the background and your tiles transparently overlayed (which Openlayers plugin will do not either).




Last Edit


I finally got success with your Maptiler tiles by using the Openlayers page that was created by Maptiler. They hacked the getURL to respect the inverse numbering:





khorog






Generated by MapTiler/GDAL2Tiles, Copyright © 2008 Klokan Petr Pridal, GDAL & OSGeo GSoC







This works with all browsers.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...