Last active
February 25, 2016 10:14
-
-
Save davidyell/0a63c0d710fa10137ae8 to your computer and use it in GitHub Desktop.
Google maps coordinate names change with every release, so this code will help to abstract those names away, allowing the processing of the coordinates regardless of their name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Abstract the google named variables to that if they change we can still read the values | |
$coords = []; | |
foreach ($bounds as $key => $value) { | |
$coords[] = $value; | |
} | |
$first = get_object_vars($coords[0]); | |
$second = get_object_vars($coords[1]); | |
$corners['brLat'] = number_format($first[key($first)], 2); | |
next($second); | |
$corners['brLng'] = number_format($second[key($second)], 2); | |
prev($second); | |
next($first); | |
$corners['tlLat'] = number_format($first[key($first)], 2); | |
$corners['tlLng'] = number_format($second[key($second)], 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment