So here’s a quick couple snippets of code that will allow you to retrieve the coordinates of two locations using Google Maps API — no API key necessary.
This first function will return the coordinates of specific address (I find pretty much anything works, whether it’s a full address with street number, or just a postal code, or simply a city name) as an array of coordinates:
function getCoordinates($address) { $url = "http://maps.google.com/maps/geo?q=" . urlencode($address) . "&output=json"; $result = file_get_contents($url); $result = json_decode($result, 1); if (isset($result['Placemark'])) { list($lat, $long) = $result['Placemark'][0]['Point']['coordinates']; } else { $lat = $long = false; } return array($lat, $long); }

