PHP code example of alexpechkarev / google-geocoder
1. Go to this page and download the library: Download alexpechkarev/google-geocoder 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/ */
return [
/*
|--------------------------------------------------------------------------
| Google Geocoder
|--------------------------------------------------------------------------
| Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA")
| into geographic coordinates (like latitude 37.423021 and longitude -122.083739),
| which you can use to place markers or position the map.
|
*/
/*
|--------------------------------------------------------------------------
| Application Key
|--------------------------------------------------------------------------
|
| Your application's API key. This key identifies your application for
| purposes of quota management. Learn how to get a key from the APIs Console.
*/
'applicationKey' => 'my-api-key',
/*
|--------------------------------------------------------------------------
| Request URL
|--------------------------------------------------------------------------
|
*/
'requestUrl' => [
'json' => 'https://maps.googleapis.com/maps/api/geocode/json?',
'xml' => 'https://maps.googleapis.com/maps/api/geocode/xml?'
],
];
use GoogleGeocoder\GoogleGeocoder;
$container['GeoCoder'] = function ($container) {
return new GoogleGeocoder($container->get('settings')['google']['geocoder']);
};
$gc = $this->container['GeoCoder'];
'applicationKey' => 'your-api-key',
$param = array("address"=>"76 Buckingham Palace Road London SW1W 9TQ");