Created
January 17, 2022 08:41
-
-
Save mikestratton/7e06a9f60c5bc23e692b7607d49301a2 to your computer and use it in GitHub Desktop.
GIS Function within Laravel Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function geoCoding($zip_code){ | |
$api = 'https://maps.googleapis.com/maps/api/geocode/json?address='; | |
$par = '&key='; | |
$goo = env('GOOGLE_KEY'); | |
$url = $api . $zip_code . $par . $goo; | |
$file = file_get_contents($url); | |
$json = json_decode($file, true); | |
$lat = $json['results'][0]['geometry']['location']['lat']; | |
$lon = $json['results'][0]['geometry']['location']['lng']; | |
$geo = array($lat, $lon); | |
return $geo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment