PHP code example of arraypress / wp-google-geocoding

1. Go to this page and download the library: Download arraypress/wp-google-geocoding 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/ */

    

arraypress / wp-google-geocoding example snippets


use ArrayPress\Google\Geocoding\Client;

$client = new Client( $api_key );
$result = $client->geocode( '10 Downing Street, London' );

if ( ! is_wp_error( $result ) ) {
	update_post_meta( $id, '_lat', $result->get_latitude() );
	update_post_meta( $id, '_lng', $result->get_longitude() );
}

use ArrayPress\Google\Geocoding\Distance;

$miles = Distance::between( $lat1, $lng1, $lat2, $lng2, 'mi' );