src/models/Coordinates.php
public function apiCall($address, $regionCode)
    {
        $result = (new GeocodingClient())->lookup([
            'key' => $this->apiServerKey,
            'address' => $address,
            'region' => $regionCode
                ]
        );
        /*
         * https://console.developers.google.com/project/263658429534/apiui/credential
         * To work, the IP where this method it's executing must be enabled y google developers console
         */
        if ($result['status'] == "REQUEST_DENIED") {
            throw new GeocodingApiException('Configuration Error: This IP is not enabled in Google Developer Console');
        }
        if ($result['status'] !== 'OK' && $result['status'] !== 'ZERO_RESULTS') {
            throw new GeocodingApiException('Request failed');
        }
        if ($result['status'] === 'OK') {
            if (isset($result['results'][0]['geometry']['location']['lng']) === false || isset($result['results'][0]['geometry']['location']['lat']) === false) {
                throw new GeocodingApiException('Unexpected Google Api Response: ' . Json::encode($result));
            }
            $this->longitude = $result['results'][0]['geometry']['location']['lng'];
            $this->latitude = $result['results'][0]['geometry']['location']['lat'];
            return true;
        } else {
            return false;
        }
    }
public function apiCall($address, $regionCode)
    {
        $result = (new GeocodingClient())->lookup([
            'key' => $this->apiServerKey,
            'address' => $address,
            'region' => $regionCode
                ]
        );
        /*
         * https://console.developers.google.com/project/263658429534/apiui/credential
         * To work, the IP where this method it's executing must be enabled y google developers console
         */
        if ($result['status'] == "REQUEST_DENIED") {
            throw new GeocodingApiException('Configuration Error: This IP is not enabled in Google Developer Console');
        }
        if ($result['status'] !== 'OK' && $result['status'] !== 'ZERO_RESULTS') {
            throw new GeocodingApiException('Request failed');
        }
        if ($result['status'] === 'OK') {
            if (isset($result['results'][0]['geometry']['location']['lng']) === false || isset($result['results'][0]['geometry']['location']['lat']) === false) {
                throw new GeocodingApiException('Unexpected Google Api Response: ' . Json::encode($result));
            }
            $this->longitude = $result['results'][0]['geometry']['location']['lng'];
            $this->latitude = $result['results'][0]['geometry']['location']['lat'];
            return true;
        } else {
            return false;
        }
    }
Calls the api to search the coordinates for the given $address and
$regionCode.

@param string $address
@param string $regionCode
@return boolean
@throws GeocodingApiException