Implementing OpenLayers3 basemap from tiles created using gdal2tiles

المشرف العام

Administrator
طاقم الإدارة
I recenty discovered the gdal2tiles.py tool which is working great with OpenLayers 2.x, but I wanted to use the new release of OL and I'm having some troubles. I have googled for a solution but i did not found a way to go.Here is my code, inspired from the solutions offered here: https://groups.google.com/forum/#!searchin/ol3-dev/TMS/ol3-dev/JLn0lfHvI7w/q7C3O8_b0-UJ (still referring to the dev version of OL3, different it seems to the release).

var tileUrlFunction = function(tileCoord, pixelRatio, projection) { if (!tileCoord) { return ""; } var x = tileCoord[1]; var y = tileCoord[2]; var z = tileCoord[0]; if (x < 0 || y < 0) { return "";} return 'http://localhost/map-tiles/'+ z.toString()+'/'+ x.toString() +'/'+y.toString() +'.png';}var layers = [ new ol.layer.Tile({ source: new ol.source.XYZ({ tileUrlFunction: tileUrlFunction }) })];var map = new ol.Map({ target: 'map', layers: layers, renderer: 'canvas', view: new ol.View({ center: [2900,-3900], zoom: 3 })});I've tried several combinations of the x, y and z assignment without success. Tiles on the browser are completely wrong and or missing.

Any help would be much appreciated.



أكثر...
 
أعلى