2

Problem

How to calculate center of each custom tile as a point (x,y) or (x,y,z) where z is zoom level, in a projection: EPSG:3857?

What I know about the tiles

  • Originally they are served as TMS
  • They represent png images 256*256
  • They are in projection: EPSG:3857
  • In OpenLayers2 they were coded like TMS layer
  • In OpenLayers3 (v.3.8.2) they are coded like XYZ layer (that includes -y) as shown in this example:

-

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

I have finally found answer to this question: https://stackoverflow.com/questions/32046601/convert-xyz-coordinate-of-a-tile-to-longitude-latitude. Thank you very much @Alvin Lindstam!

For future references I just want to mention the meaning of the result:

10, 510, -341 -> 10, 510, -341     <----- z/x/y of tile
-78271.51696402207, 6692214.700423751, -39135.75848200917, 6731350.458905762 <----- first point: left down corner of the tile, second point: right upper corner of the tile
-58703.63772301562, 6711782.579664757 <----- point: center 

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.