Java tutorial
//package com.java2s; public class Main { public static double pixelXToLongitude(int pixelX, double zoomLevel, int tileSize) { int mapSize = getMapSize(zoomLevel, tileSize); if (pixelX < 0 || pixelX > mapSize) { throw new IllegalArgumentException( "invalid pixelX coordinate at zoom level " + zoomLevel + ": " + pixelX); } return 360d * pixelX / mapSize - 180d; } public static int getMapSize(double zoomLevel, int tileSize) { return (int) Math.pow(2d, getZoomLevelAsInt(zoomLevel)) * getTileSize(zoomLevel, tileSize); } public static int getZoomLevelAsInt(double zoomLevel) { return (int) Math.round(zoomLevel); } public static int getTileSize(double zoomLevel, int tileSize) { double f = zoomLevel - Math.floor(zoomLevel); f = f < .5f ? f + 1f : .5f * (f + 1f); return (int) (tileSize * f); } }