Skip to content

Instantly share code, notes, and snippets.

@thesubhendu
Last active January 8, 2019 16:04
Show Gist options
  • Save thesubhendu/3c052f28c9688498a4093220b88e62a5 to your computer and use it in GitHub Desktop.
Save thesubhendu/3c052f28c9688498a4093220b88e62a5 to your computer and use it in GitHub Desktop.
<?php
public function geoCodeLatLng($lat, $lng)
{
$googleGeocodeApiUrl=
"https://maps.googleapis.com/maps/api/geocode/json?latlng=$lat,$lng&key=".config('googlemapjs.key');
$response = json_decode(file_get_contents($googleGeocodeApiUrl));
if (!$response) {
throw new \Exception('Could not geocode');
}
$geoCodedResult=$response->results[0];
$this->cacheGeoCodedResult($geoCodedResult);
return $response->results[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment