Example #1
0
 public function fromPointToLatLng($point)
 {
     $me = $this;
     $origin = $me->pixelOrigin_;
     $lng = ($point->x - $origin->x) / $me->pixelsPerLonDegree_;
     $latRadians = ($point->y - $origin->y) / -$me->pixelsPerLonRadian_;
     $lat = radiansToDegrees(2 * atan(exp($latRadians)) - M_PI / 2);
     return new G_LatLng($lat, $lng);
 }
Example #2
0
function transToGoogle($x, $y, $scale)
{
    $TILE_SIZE = 2048 / $scale;
    //print_r($TILE_SIZE."<br>");
    $point = array("x" => $TILE_SIZE / 2, "y" => $TILE_SIZE / 2);
    $pixelsPerLonDegree_ = $TILE_SIZE / 360;
    $pixelsPerLonRadian_ = $TILE_SIZE / (2 * pi());
    $lng = $x / $pixelsPerLonDegree_;
    $latRadians = $y / -$pixelsPerLonRadian_;
    $lat = radiansToDegrees(2 * atan(exp($latRadians)) - pi() / 2);
    return array("X" => $lng, "Y" => $lat);
}