Download the PHP package langleyfoxall/simple-google-maps without Composer
On this page you can find all versions of the php package langleyfoxall/simple-google-maps. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download langleyfoxall/simple-google-maps
More information about langleyfoxall/simple-google-maps
Files in langleyfoxall/simple-google-maps
Package simple-google-maps
Short Description Simple PHP client for various Google Maps APIs
License LGPL-3.0-only
Informations about the package simple-google-maps
PHP Simple Google Maps
This package provides a simple PHP client for various Google Maps APIs.
Installation
To install, just run the following composer command.
Remember to include the vendor/autoload.php
file if your framework does not do this for you.
Usage
To use Simple Google Maps, you must first create a new instance. This can be done is two ways,
dependant on whether you have a standard API key
, or a clientName
and cryptKey
(for enterprise
/ premium plans).
Geocoding
To convert an address to a set of GPS coordinates, use the geocode
method, as shown below.
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.
The above method will return a object of type LatLong
, which allows you to access the GPS coordinates as
shown below.
You can also calculate the distance between two LatLong
objects by using the distanceTo
method. The
distance is returned in kilometers, and takes into account the curvature of the Earth using the Haversine
formula.
Reverse Geocoding
To lookup an address from a set of GPS coordinate, use the reverseGeocode
method, as shown below.
This method will return a string containing the address found at the specified coordinates. If no address
could be found, null
will be returned.
Directions
To find the directions between two points, use the directions
method. The methods expects
three parameters, the origin, the destination, and optionally the travel mode as defined by the
TravelMode
enum.
See the example usage below.
This will produce output similar to the following.
All versions of simple-google-maps with dependencies
divineomega/do-file-cache Version ^2.0
divineomega/php-distance Version ^1.0
laravel/framework Version ^5.1||^6.0||^7.0||^8.0||^9.0||^10.0||^11.0
ext-json Version *
php Version >=7.0||>=8.0