瓦片计算ZXY
#epsg:3857 web mercator
#lon=[-180,180],lat=[-85.05112877980659,85.05112877980659]
function getTileZXY(lat, lon, zoom) { var xtile = parseInt(Math.floor( (lon + 180) / 360 * (1<<zoom) )); var ytile = parseInt(Math.floor( (1 - Math.log(Math.tan(lat.toRad()) + 1 / Math.cos(lat.toRad())) / Math.PI) / 2 * (1<<zoom) )); return "" + zoom + "/" + xtile + "/" + ytile; }
#epsg:4326 or 4490
function getTileZXY(lat, lon, zoom) { var xtile = parseInt(Math.floor( (lon + 180) / 180 * (1<<zoom) )); var ytile = parseInt(Math.floor( (lat + 90)/180 * (1<<zoom) )); return "" + zoom + "/" + xtile + "/" + ytile; }