Skip to content

Instantly share code, notes, and snippets.

@davidyell
Last active February 25, 2016 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidyell/0a63c0d710fa10137ae8 to your computer and use it in GitHub Desktop.
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.
<?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