Google co-ordinate system ... PHP code
Just spent a few annoying hours working this function out.
Google Maps 3 API, the one I'm using to upgrade this site, has a fantastic overlay system, but I was left with Google Maps "x,y,zoom" data in PHP, and I wanted LatLng format to quiz the database. You can do this using the Projection.fromPointToLatLng() Javascript function, but you don't have access to these in the PHP server encironment. So here's the replacement:
function fromPointToLatLng($intX, $intY, $intZoom) { $c=pow(2,$intZoom); $x=360/$c*$intX-180; $y=180-360/$c*$intY; $fpLong=$x; $fpLat= (2.0*atan(exp($y /180*M_PI))-M_PI/2.0)*180/M_PI; return array( $fpLat, $fpLong); }
Such that:
list($fpLat, $fpLong)=fromPointToLatLng($intX, $intY, $intZoom);
For more, see Maps API V3 Overlays - Google Maps JavaScript API V3 - Google Code
All questions
In this section