Skip to content

Commit 2054b9f

Browse files
committed
Update docs
1 parent b321acb commit 2054b9f

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed

README.md

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,46 @@ Remember to include the `vendor/autoload.php` file if your framework does not do
99

1010
## Usage
1111

12-
Creating the SimpleGoogleMaps Object can be done in one of two ways.
13-
14-
The first way is to pass through just the API key that you are provided upon registering for the Google Maps API.
15-
12+
To use Simple Google Maps, you must first create a new instance. This can be done is two ways,
13+
dependant on whether you have a standard API `key`, or a `clientName` and `cryptKey` (for enterprise
14+
/ premium plans).
1615

1716
```php
18-
use LangleyFoxall\SimpleGoogleMaps\Factories\SimpleGoogleMapsFactory;
19-
$simpleGoogleMaps = SimpleGoogleMapsFactory::getByKey("[APIKEY]");
20-
```
17+
// Standard authentication:
18+
$simpleGoogleMaps = SimpleGoogleMapsFactory::getByKey(getenv('KEY'));
2119

22-
The second way is to provide your client name and the crypt key that you are provided with upon creating a Google enterprise account.
23-
24-
```php
25-
use LangleyFoxall\SimpleGoogleMaps\Factories\SimpleGoogleMapsFactory;
26-
$simpleGoogleMaps = SimpleGoogleMapsFactory::getByClientNameAndCryptKey("[CLIENTNAME]","[CRYPTKEY]");
20+
// Enterprise / premium plan authentication:
21+
$simpleGoogleMaps = SimpleGoogleMapsFactory::getByClientNameAndCryptKey(getenv('CLIENT_NAME'), getenv('CRYPT_KEY'));
2722
```
2823

29-
Once you have created the object you can then get the coordinates from an address via the `getByAddress` method.
24+
## Geocoding
25+
26+
To convert an address to a set of GPS coordinates, use the `geocode` method, as shown below.
3027

3128
```php
32-
$addressline = "10 Downing St, Westminster, London SW1A UK";
33-
$homeCoords = $simpleGoogleMaps->getByAddress($addressline);
29+
$latLng = $simpleGoogleMaps->geocode('10 Downing St, Westminster, London SW1A UK');
3430
```
3531

36-
Optionally, you can allow partial matches to be returned if your input address is not highly accurate. You can do so with the `allowPartialMatches` method, as shown below.
32+
Optionally, you can allow partial matches to be returned if your input address is not highly accurate.
33+
You can do so with the `allowPartialMatches` method, as shown below.
3734

3835
```php
39-
$simpleGoogleMaps->allowPartialMatches();
40-
$homeCoords = $simpleGoogleMaps->getByAddress('test address');
36+
$latLng = $simpleGoogleMaps->allowPartialMatches()->geocode('test address');
4137
```
4238

43-
The above method will return a object of type LatLong, this allows you to access the coordinates like so.
39+
The above method will return a object of type `LatLong`, which allows you to access the GPS coordinates as
40+
shown below.
4441

4542
```php
46-
$latitude = $homeCoords->lat;
47-
$longitude = $homeCoords->long;
43+
$latitude = $latLng->lat;
44+
$longitude = $latLng->long;
4845
```
4946

50-
You can also calculate the distance between two LatLong objects by using the `distanceTo` method on the LatLong Object.
47+
You can also calculate the distance between two `LatLong` objects by using the `distanceTo` method.
5148

5249
```php
53-
$milesBetween = $homeCoords->distanceTo($toCoords);
50+
$kilometresDistance = $homeCoords->distanceTo($toCoords);
5451
```
5552

56-
By default this will return the answer in miles, you may also request the distance in kilometres by adding it to the method call.
57-
58-
```php
59-
$milesBetween = $homeCoords->distanceTo($toCoords,"kilometres");
60-
```
6153

6254

0 commit comments

Comments
 (0)