Menu buttonMENU    UK Free TV logo Help!
securesearchsettings

 

 

Click to see updates
To join, leave or change ukfree.tv updates by email, enter your email address here:
 

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)
{
$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
My Freeview box has no EPG, is blank on FIVE, ITV3, ITV4, ITV2+1, has no sound o1
Can I stop paying Sky and use my satellite receiver to get Freeview ?2
What can I do when my Sky Digibox says 'No Signal' or 'Technical fau3
My Sky box has a "no signal message" - what do I do?4
How do I change the RF output channel on a Sky Digibox?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

Comments

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.