Skip to content

Instantly share code, notes, and snippets.

@shawnbot
Created March 13, 2013 18:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawnbot/5154609 to your computer and use it in GitHub Desktop.
Save shawnbot/5154609 to your computer and use it in GitHub Desktop.
A Leaflet TileLayer class for loading "compact" URL schemes.
L.CompactTileLayer = L.TileLayer.extend({
getTileUrl: function(tilePoint) {
this._adjustTilePoint(tilePoint);
var col = String("000000" + tilePoint.x).slice(String(tilePoint.x).length),
row = String("000000" + tilePoint.y).slice(String(tilePoint.y).length),
zoom = this._getZoomForUrl();
return this._url
.replace("{z}", zoom)
.replace("{x}", col.slice(0, 3) + "/" + col.slice(3, 6))
.replace("{y}", row.slice(0, 3) + "/" + row.slice(3, 6));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment