problem with tilemill #96

taniki opened this Issue Aug 28, 2011 · 4 comments


None yet

3 participants

taniki commented Aug 28, 2011

don't know if the problem is about polymaps or tilemill.

When exporting mbtiles from tilemill and showing them in polymaps. The tiles seem having a wrong Y and then displaying a weird map. Maybe it is a parameter problem but didn't find any that will display the map correctly.


Polymaps usually uses X and Y tile coordinates starting at the top left (north west). TileMill currently uses TMS coordinates which start at the bottom left (south west). Here's a good explanation:

Specifically, to convert back and forth between TMS and polymaps coordinates, you need only flip the y axis:

var ymax = 1 << zoom;
var y = ymax - y - 1;
@RandomEtc RandomEtc closed this Aug 28, 2011
taniki commented Aug 28, 2011

Thanks ! Just understood by reading the tilestach examples and the mbtiles specifications.

I wrote the little function to produce the url, is it interesting for the polymaps doc or something else ?

function tilestream(template) {
  /** Formats the specified number per TileStache. */
  return function(c) {
    var max = 1 << c.zoom;
    var column = c.column % max;
    if (column < 0) column += max;
    var row = max - c.row - 1;

    return template.replace(/{(.)}/g, function(s, v) {
      switch (v) {
        case "Z": return c.zoom;
        case "X": return column;
        case "Y": return row;
      return v;
tmcw commented Aug 28, 2011

@taniki Are you using TileStream for serving those tiles? You can just replace /1.0.0/ in the URL with /2.0.0/ and you won't need to convert any of the coordinates - TileStream serves tiles as XYZ from the /2.0.0/ endpoint.

taniki commented Aug 28, 2011

ow ... yep using tilestream. am i dumb or is it nowhere on the net ?

thanks for the tips (:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment