menuMENU    UK Free TV logo Archive (2002-)



Click to see updates

Google co-ordinate system ... PHP code

There's little documentation to convert Google Maps 3 co-ordinates to WGS84 latitude/longitude, here's my handy little function...

There's little documentation to convert Google Maps 3 co-ordina
published on UK Free TV

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)
$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
BBC Three Linear channel re-opens1
Removing all barriers to communication between diverse cultures2
How do I get a test card with Freeview3
What can I do when my Sky Digibox says 'No Signal' or 'Technical fau4
Can I receive UK TV in Ghana?5
In this section
Seeing something different? We are doing A/B testing on a new Material Design1
Please share your thoughts about UK FREE TV2
The next 50 things on UK FREE TV. What would you like to see? 3
UK Free TV now uses friendly web addresses4
Best ever emails and improved menus on UK FREE TV5
Use the Knowledge base to find answers to your technical problems6


Your comment please
Please post a question, answer or commentUK Free TV is here to help people. If you are rude or disrespectful all of your posts will be deleted and you will be banned.

Privacy policy: UK Free Privacy policy.