Skip to content

Instantly share code, notes, and snippets.

@slopjong
Created May 31, 2014 08:53
Show Gist options
  • Save slopjong/b4ed79cc76f9f7057a1d to your computer and use it in GitHub Desktop.
Save slopjong/b4ed79cc76f9f7057a1d to your computer and use it in GitHub Desktop.
<?php
$zoom = 0;
$n = pow(2, $zoom);
$lon = 6.07057;
$lat = 49.61629;
$xtile = floor((($lon + 180) / 360) * pow(2, $zoom)) + 0.5;
$ytile = floor((1 - log(tan(deg2rad($lat)) + 1 / cos(deg2rad($lat))) / pi()) /2 * pow(2, $zoom)) + 0.5;
echo "<html><body>";
echo '<a target="_blank" href="http://c.tile.openstreetmap.org/'. $n .'/'. $xtile .'/'. $ytile .'.png">http://c.tile.openstreetmap.org/'. $n .'/'. $xtile .'/'. $ytile .'.png</a>';
echo "</body></html>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment