<?php
/**
* private getCoordinates()
*/
private function getCoordinates($address = false)
{
if (!$address) {
return false;
}
$url = 'https://maps.googleapis.com/maps/api/geocode/json?sensor=true&address=';
$url .= urlencode($address);
$ch = curl_init();
$timeout = 60;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$data = curl_exec($ch);
curl_close($ch);
return json_decode($data);
}
//------------------------------------------------------------------