Download the PHP package biscolab/google-maps-php-sdk without Composer

On this page you can find all versions of the php package biscolab/google-maps-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package google-maps-php-sdk

Google Maps PHP SDK

Packagist version Scrutinizer Build Status

Google Maps PHP (unofficial library). This provide simple functions to work with Google Maps APIs. You can find further informations in Google Maps Platform Documentation

Google Maps provide many services, actually at this moment this package implements only Geocoding service but others will be available soon.

Reference & Documentation

Go to complete reference or read documentation

Google Maps Services

Ready

ASAP

Not scheduled

Installation

You can install the package via composer:

Examples

Watch the examples

License

MIT License

Documentation

This provide simple functions to work with Google Maps APIs. You can find further informations in Google Maps Platform Documentation

Reference

You can find complete API references

Google Maps Services

Ready

ASAP

Not scheduled

System requirements

PHP 7.1 or greater

Composer

Install the package via composer:

Notice! The package is not yet stable, you may find trouble with your minimum stability settings. Further documentation coming asap.

Google Maps is a service supplied by Google and first of all you must register your app project on the Google Cloud Platform Console and get a Google API key which you can add to your app or website (source: official Google Maps documentation).

  1. Read the Pricing table
  2. Create your project by clicking on "Get started"
  3. Create project credentials
  4. Enable services (Geocoding API, Elevation API, etc...)

Google Console

Google Console main page

Geocoding API

The Geocoding API is a service that provides geocoding and reverse geocoding of addresses.

Official Google Geocoding documentation

Initialize Geocoding Object

First of all replace YOUR_API_KEY with your actual API key.

Get results

You have 3 different ways to retrieve data of your place!

Go to complete SDK reference

Geocoding (Latitude/Longitude Lookup) by address as string

Official Google documentation

getByAddress accept following arguments:

Name Required Type Description
address yes string The street address or plus code that you want to geocode
region no string The region code, specified as a ccTLD ("top-level domain") two-character value. More info here

Change response language using setLanguage method

You can find the list of supported languages here: https://developers.google.com/maps/faq#languagesupport

Reverse Geocoding (Address Lookup) by Location/LatLng object

Official Google documentation

getByLatLng (getReverse alias is deprecated) accept a LatLng object which represents the location of the place.

Change response language using setLanguage method

You can find the list of supported languages here: https://developers.google.com/maps/faq#languagesupport

By Place ID as string

getByPlaceId accept as parameter the address the place ID.

Use results

Results is/are a Biscolab\GoogleMaps\Http\GeocodingResultsCollection object.
First thing you should know how many results there are in your GeocodingResultsCollection using count method.

To retrieve the first result you can use the first method:

$first_result is an instance of GeocodingResult class and has the following methods:

Method name Return Type
getAddressComponents() Address
getFormattedAddress() string
getGeometry() Geometry
getPlaceId() string
getTypes() array

Elevation API

The Elevation API provides elevation data for all locations on the surface of the earth, including depth locations on the ocean floor (which return negative values).

There are two types of request:

At the moment this package support only Positional Requests but I'm working on Sampled Path Requests and it will be available soon.

Official Google Elevation documentation

Initialize Elevation Object

First of all replace YOUR_API_KEY with your actual API key.

Get results (Positional Requests)

First of all you have to prepare the locations variable, it can be a single Location object, an array of Location objects or a polyline string.

Single Location object

Create a Location object using latitude and longitude.

Array of Location objects

Using multiple Location objects inside an array

Polyline encoded string

Encode a location using the Encoded Polyline Algorithm Format

Make API call

Get results (Sampled Path Requests)

First of all you have to prepare the path variable, it can be an array of Location objects or a polyline string.

Array of Location objects

Using multiple Location objects inside an array

Polyline encoded string

Encode a location using the Encoded Polyline Algorithm Format

Make API call

Use results

Results is/are a Biscolab\GoogleMaps\Http\ElevationResultsCollection object.
First thing you should know how many results there are in your ElevationResultsCollection using count method.

To retrieve the first result you can use the first method:

$first_result is an instance of ElevationResult class and has the following methods:

Method name Return Type
getLocation() Location
getElevation() float
getResolution() float

Places API

The Places API allows you to query for place information on a variety of categories, such as: establishments, prominent points of interest, geographic locations, and more. You can search for places either by proximity or a text string (credits: Official Documentation website.

There are 3 types of request:

Official Google Place documentation

Initialize Places Object

First of all replace YOUR_API_KEY with your actual API key.

Find Places requests

This function takes a text input (name, address or phone number) and returns a place.

Using name or address

Search place using the "name" or "address".

findPlaceByText method accepts 3 arguments

Name Type Description Default
$query string The address (or the name) specifying which place to search for Required
$params array The list of search params to add to API request []
$fields array The fields specifying the types of place data to return []

Find further details about request fields (required, types, etc...) here: https://developers.google.com/places/web-service/search#FindPlaceRequests

Using phone number

Search place using the "phone number".

findPlaceByPhoneNumber method accepts 3 arguments

Name Type Description Default
$number string The phone number specifying which place to search for Required
$params array The list of search params to add to API request []
$fields array The fields specifying the types of place data to return []

Find further details about request fields (required, types, etc...) here: https://developers.google.com/places/web-service/search#FindPlaceRequests

Nearby Search requests

This function looks for places within a specified area.

Using location & radius

findNearbyPlaceByRadius method accepts 3 arguments

Name Type Description Default
$location Location must be instance of Biscolab\GoogleMaps\Object\Location class Required
$radius int defines the distance in meters. Maximum allowed value is 50000. Required
$params array additional parameters to add to API call []

Rank by distance

findNearbyPlaceByDistance method accepts 2 arguments

Name Type Description Default
$location Location must be instance of Biscolab\GoogleMaps\Object\Location class Required
$params array additional parameters to add to API call. You MUST set at least one of following values: keyword, name, type []

Find further details about request fields (required, types, etc...) here: https://developers.google.com/places/web-service/search#PlaceSearchRequests

Text Search request

This service returns information about a set of places based on a string.

Search by query

textSearch method accepts 2 arguments

Name Type Description Default
$query string The text string on which to search, for example: "restaurant" or "123 Main Street". Required
$params array additional parameters to add to API call []

Find further details about request fields (required, types, etc...) here: https://developers.google.com/places/web-service/search#TextSearchRequests

Place's Details

details method accepts 2 arguments

Name Type Description Default
$place_id string A textual identifier that uniquely identifies a place, returned from a Place Search. Required
$params array additional parameters to add to API call []

Find further details about request fields (required, types, etc...) here: https://developers.google.com/places/web-service/details#PlaceDetailsRequests

Use results

Results is/are a Biscolab\GoogleMaps\Http\PlaceResultsCollection object.

Current page

First thing you should know how many results there are in your PlaceResultsCollection using count method.

To retrieve the first result you can use the first method:

$first_result is an instance of PlaceResult class and has the following methods:

Method name Return Type
getPhotos() PhotoCollection
getGeometry() Geometry
getFormattedAddress() string
getName() string
getIcon() string
getId() string
getPlaceId() string
getReference() string
getVicinity() string
getTypes() array
getOpeningHours() array
getPriceLevel() int
getRating() float
getPermanentlyClose() bool
getPlusCode() array

Next result page

Results can be paginated. How do you know id a result has more pages?

`

Time Zone API

The Time Zone API provides time offset data for locations on the surface of the earth

Official Google TimeZone documentation

Initialize TimeZone Object

First of all replace YOUR_API_KEY with your actual API key.

Get result

Go to complete SDK reference

By location and timestamp

get accepts 3 arguments

Name Requested Type Description
$location Yes Biscolab\GoogleMaps\Object\Location Represents the location to look up
$timestamp Yes integer The Time Zone API uses the $timestamp to determine whether or not Daylight Savings should be applied, based on the time zone of the $location
$language No string The language in which to return results

Use result

Result is an instance of Biscolab\GoogleMaps\Http\Result\TimeZoneResult class and has the following methods:

Method name Return Type
getDdstOffset() int
getRawOffset() int
getTimeZoneId() string
getTimeZoneName() string

All versions of google-maps-php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
guzzlehttp/guzzle Version 5.*|6.*|7.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package biscolab/google-maps-php-sdk contains the following files

Loading the files please wait ....