2017 © Pedro Peláez
 

library simple-google-maps-api

a simple api for the google maps services

image

rapidwebltd/simple-google-maps-api

a simple api for the google maps services

  • Monday, January 29, 2018
  • by DivineOmega
  • Repository
  • 1 Watchers
  • 1 Stars
  • 296 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 28 % Grown

The README.md

This library allows a user to easily communicate with the Google Maps API and retrieve a set of coordinates from an address., (*1)

Installation

To install, just run the following composer command., (*2)

composer require rapidwebltd/simple-google-maps-api, (*3)

Remember to include the vendor/autoload.php file if your framework does not do this for you., (*4)

Usage

Creating the SimpleGoogleMaps Object can be done in one of two ways., (*5)

The first way is to pass through just the API key that you are provided upon registering for the Google Maps API., (*6)

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

The second way is to provide your client name and the crypt key that you are provided with upon creating a Google enterprise account., (*7)

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

Once you have created the object you can then get the coordinates from an address via the getByAddress method., (*8)

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

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., (*9)

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

The above method will return a object of type LatLong, this allows you to access the coordinates like so., (*10)

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

You can also calculate the distance between two LatLong objects by using the distanceTo method on the LatLong Object., (*11)

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

By default this will return the answer in miles, you may also request the distance in kilometres by adding it to the method call., (*12)

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

The Versions

29/01 2018

dev-master

9999999-dev

a simple api for the google maps services

  Sources   Download

LGPL3 LGPL-3.0-only

The Requires

 

by Jordan Hall
by Andrew McDonald

29/01 2018

v2.0.2

2.0.2.0

a simple api for the google maps services

  Sources   Download

LGPL-3.0-only

The Requires

 

by Jordan Hall
by Andrew McDonald

23/08 2017

v2.0.0

2.0.0.0

a simple api for the google maps services

  Sources   Download

LGPL3

The Requires

 

by Andrew McDonald

06/07 2017

v1.2.1

1.2.1.0

a simple api for the google maps services

  Sources   Download

LGPL3

The Requires

 

by Andrew McDonald

06/07 2017

v1.2.0

1.2.0.0

a simple api for the google maps services

  Sources   Download

LGPL3

The Requires

 

by Andrew McDonald

27/06 2017

v1.1.2

1.1.2.0

a simple api for the google maps services

  Sources   Download

LGPL3

The Requires

 

by Andrew McDonald

22/06 2017

v1.1.1

1.1.1.0

a simple api for the google maps services

  Sources   Download

LGPL3

The Requires

 

by Andrew McDonald

05/04 2017

v1.1.0

1.1.0.0

a simple api for the google maps services

  Sources   Download

LGPL3

The Requires

 

by Andrew McDonald

03/04 2017

v1.0.2

1.0.2.0

a simple api for the google maps services

  Sources   Download

LGPL3

The Requires

 

by Andrew McDonald

29/03 2017

v1.0.1

1.0.1.0

a simple api for the google maps services

  Sources   Download

LGPL3

The Requires

 

by Andrew McDonald

29/03 2017

v1.0.0

1.0.0.0

a simple api for the google maps services

  Sources   Download

LGPL3

The Requires

 

by Andrew McDonald