My custom tile layer:

var baseLayer = new ol.layer.Tile({
  source: new ol.source.XYZ({
    url: 'http://path/to/the/tiles/base/{z}/{x}/{-y}.png'

How can I return z/x/y numbering for one tile (as an example) and for all tiles (as wanted result) with OpenLayers3 (it would be nice if I could get the result over console too, becuase I am trying to figure out how to use it) and export them as geojson or csv?


Possibly do you mean on the fly, as in tileGrid?

      new ol.layer.VectorTile({
        source: new ol.source.VectorTile({
          format: new ol.format.GeoJSON(),
          tilePixelRatio: 16,
          tileLoadFunction: function(foo,bar,source),
          tileGrid: ol.tilegrid.createXYZ({maxZoom: 22}),
          url: 'tilesource/{z}/{x}/{y}.json'

And the loop in and digest the source url during the tile loader with console log, or better, by posting the data to a database or an array and into a file somewhere.

I leave it up to the pros though, several libraries are available to create vectortiles on the fly (as opposed to manually clipping boundaries), like tilecache and osm2vectortiles.

| improve this answer | |
  • thnx for quick respond! Lets first solve this issues...On line tileLoadFunction: function(foo,bar,source), I have: "Uncaught SyntacError:Unexpected token ," If I remove it, I got on line tileGrid: ol.tilegrid.createXYZ({maxZoom: 22}),: Uncaught SyntaxError: Unexpected identifier Am I suppose to change something in function(foo,bar,source) in parameters? Noob here – vayacondios2015 Nov 1 '16 at 14:49
  • without knowing your tileLoadFunction, I can't help debug your token request; the error you are getting is likely related to the url itself (eg. many third party url sources require token auth params added to the url string), or how you may be handling the errors. good luck, maybe this link helps? stackoverflow.com/questions/3143698/… – Scott Close Dec 13 '17 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.