PHP code example of rapidwebltd / simple-google-maps-api

1. Go to this page and download the library: Download rapidwebltd/simple-google-maps-api 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/ */

    

rapidwebltd / simple-google-maps-api example snippets


use RapidWeb\SimpleGoogleMaps\Factories\SimpleGoogleMapsFactory;
$simpleGoogleMaps = SimpleGoogleMapsFactory::getByKey("[APIKEY]");

use RapidWeb\SimpleGoogleMaps\Factories\SimpleGoogleMapsFactory;
$simpleGoogleMaps = SimpleGoogleMapsFactory::getByClientNameAndCryptKey("[CLIENTNAME]","[CRYPTKEY]");

$addressline = "10 Downing St, Westminster, London SW1A UK";
$homeCoords = $simpleGoogleMaps->getByAddress($addressline);

$simpleGoogleMaps->allowPartialMatches();
$homeCoords = $simpleGoogleMaps->getByAddress('test address');

$latitude = $homeCoords->lat;
$longitude = $homeCoords->long;

$milesBetween = $homeCoords->distanceTo($toCoords);

$milesBetween = $homeCoords->distanceTo($toCoords,"kilometres");