[javascript] / trunk / google_maps_nojs / Google / Maps.php Repository:
ViewVC logotype

View of /trunk/google_maps_nojs/Google/Maps.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 398 - (download) (annotate)
Sat Jun 14 21:30:49 2008 UTC (2 years, 2 months ago) by tuupola
File size: 1474 byte(s)
Add demo for clickable markers in static map. Update method names in
Google_Maps class.

<?php

class Google_Maps {
            
    static function 
LonToX($lon) {
        
$offset 268435456
        
$radius $offset pi();
        return 
round($offset $radius $lon pi() / 180);        
    }

    static function 
LatToY($lat) {
        
$offset 268435456
        
$radius $offset pi(); 
        return 
round($offset $radius log((sin($lat pi() / 180)) / (sin($lat pi() / 180))) / 2);
    }

    static function 
XToLon($x) {
        
$offset 268435456
        
$radius $offset pi();
        return ((
round($x) - $offset) / $radius) * 180pi();  
    }
    
    static function 
YToLat($y) {
        
$offset 268435456
        
$radius $offset pi();       
        return (
pi() / atan(exp((round($y) - $offset) / $radius))) * 180 pi(); 
    }
    
    static function 
adjustLonByPixels($lon$delta$zoom) {
        return 
Google_Maps::XToLon(Google_Maps::LonToX($lon) + ($delta << (21 $zoom)));
    }

    static function 
adjustLatByPixels($lat$delta$zoom) {
        return 
Google_Maps::YToLat(Google_Maps::LatToY($lat) + ($delta << (21 $zoom)));
    }

}
/*
print $x = Google_Maps::LtoX(58.38133351447725) . "\n";
print $y = Google_Maps::LtoY(24.516592025756836) . "\n";
print $x = Google_Maps::XtoL($x) . "\n";
print $y = Google_Maps::YtoL($y) . "\n";
print Google_Maps::adjustLonByPixels(58.38133351447725, 100, 10) . "\n";
print Google_Maps::adjustLatByPixels(24.516592025756836, 100, 10) . "\n";
*/

Mika Tuupola
ViewVC Help
Powered by ViewVC 1.1-dev