1000 || $Height > 1000) exit; $ImageWidth = 256; for($Z = 5; $Z < 17; $Z++){ $Pow2 = pow(2,$Z); $MapWidth = $Pow2 * $ImageWidth; $InputWidth = $dx * $MapWidth; $InputHeight = $dy * $MapWidth; $Ratio1 = $InputWidth / $Width; $Ratio2 = $InputHeight / $Height; $Ratio = min($Ratio1, $Ratio2); if($InputWidth < 2560 && $InputHeight < 2560 && $Ratio >= 1){ $cx = $Pow2 * ($X2 + $X1) / 2.0; $cy = $Pow2 * ($Y2 + $Y1) / 2.0; $icx = floor($cx); $icy = floor($cy); $fcx = $cx - $icx; $fcy = $cy - $icy; $nx = ceil($InputWidth / $ImageWidth); $ny = ceil($InputHeight / $ImageWidth) ; $Image = imagecreatetruecolor($InputWidth, $InputHeight); if($nx * $ny * 4 < 1000){ for($ix = -$nx; $ix <= $nx; $ix++){ for($iy = -$ny; $iy <= $ny; $iy++){ $X = $icx + $ix; $Y = $icy + $iy; if(1) $UrlTemplate = "http://tile.openstreetmap.org/%d/%d/%d.png"; else $UrlTemplate = "http://tah.dev.openstreetmap.org/Tiles/tile/%d/%d/%d.png"; $URL = sprintf( $UrlTemplate, $Z, $X, $Y); $SubImage = imagecreatefrompng($URL); imagecopy( $Image, $SubImage, ($InputWidth / 2) - (($fcx - $ix)* $ImageWidth), ($InputHeight / 2) - (($fcy - $iy) * $ImageWidth), 0, 0, $ImageWidth, $ImageWidth); } } $ImageOutput = imagecreatetruecolor($Width, $Height); imagecopyresampled( $ImageOutput, $Image, 0, 0, 0, 0, $Width, $Height, $InputWidth, $InputHeight); header("Content-type: Image/PNG"); imagepng($ImageOutput); exit; } } } ?>