Skip to content

Instantly share code, notes, and snippets.

@amiller
Created January 21, 2011 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amiller/789260 to your computer and use it in GitHub Desktop.
Save amiller/789260 to your computer and use it in GitHub Desktop.
tilelayer.getTileUrl = function(tile,zoom) {
if ((zoom < mapMinZoom) || (zoom > mapMaxZoom)) {
return "http://www.maptiler.org/img/none.png";
}
var ymax = 1 << zoom;
var y = ymax - tile.y -1;
var tileBounds = new GLatLngBounds(
mercator.fromPixelToLatLng( new GPoint( (tile.x)*256, (tile.y+1)*256 ) , zoom ),
mercator.fromPixelToLatLng( new GPoint( (tile.x+1)*256, (tile.y)*256 ) , zoom )
);
if (mapBounds.intersects(tileBounds)) {
return zoom+"/"+tile.x+"/"+y+".jpg";
} else {
return "http://www.maptiler.org/img/none.png";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment