PHP code example of dmitrymomot / geocode
1. Go to this page and download the library: Download dmitrymomot/geocode library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dmitrymomot / geocode example snippets
'Jcf\Geocode\GeocodeServiceProvider',
'Geocode' => 'Jcf\Geocode\Facades\Geocode'
$response = Geocode::make()->address('1 Infinite Loop');
if ($response) {
echo $response->latitude();
echo $response->longitude();
echo $response->formattedAddress();
echo $response->locationType();
}
// Output
// 37.331741
// -122.0303329
// 1 Infinite Loop, Cupertino, CA 95014, USA
// ROOFTOP
$response = Geocode::make()->latLng(40.7637931,-73.9722014);
if ($response) {
echo $response->latitude();
echo $response->longitude();
echo $response->formattedAddress();
echo $response->locationType();
}
// Output
// 40.7637931
// -73.9722014
// 767 5th Avenue, New York, NY 10153, USA
// ROOFTOP
$response = Geocode::make()->latLng(40.7637931,-73.9722014);
if ($response) {
echo $response->raw()->address_components[8]['types'][0];
echo $response->raw()->address_components[8]['long_name'];
}
// Output
// postal_code
// 10153
sh
php composer.phar update