PHPackages                             biscolab/google-maps-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. biscolab/google-maps-php-sdk

ActiveLibrary[API Development](/categories/api)

biscolab/google-maps-php-sdk
============================

Google Maps PHP SDK.

0.9.0(4y ago)15225.0k↓31.9%12[3 issues](https://github.com/biscolab/google-maps-php-sdk/issues)MITPHPPHP ^8.0CI failing

Since Sep 5Pushed 3y ago3 watchersCompare

[ Source](https://github.com/biscolab/google-maps-php-sdk)[ Packagist](https://packagist.org/packages/biscolab/google-maps-php-sdk)[ RSS](/packages/biscolab-google-maps-php-sdk/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (7)Dependencies (5)Versions (15)Used By (0)

Google Maps PHP SDK
===================

[](#google-maps-php-sdk)

[![Packagist version](https://camo.githubusercontent.com/98558574e37d44db84404b55ae3c2e77549e877ec06f70963b37560be710c211/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626973636f6c61622f676f6f676c652d6d6170732d7068702d73646b2e737667)](https://packagist.org/packages/biscolab/google-maps-php-sdk) [![Scrutinizer](https://camo.githubusercontent.com/8a34dab499e5d991e90152d00fb1f818be2c6c6af716fcaa9c13c59e2b2defd7/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f626973636f6c61622f676f6f676c652d6d6170732d7068702d73646b2e737667)](https://scrutinizer-ci.com/g/biscolab/google-maps-php-sdk/) [![Build Status](https://camo.githubusercontent.com/35b69742d203359ec8c558e263bd97881a5b6a51e0c228534593d4b8eb22791b/68747470733a2f2f7472617669732d63692e6f72672f626973636f6c61622f676f6f676c652d6d6170732d7068702d73646b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/biscolab/google-maps-php-sdk)

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](https://developers.google.com/maps/documentation/)

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

Reference &amp; Documentation
-----------------------------

[](#reference--documentation)

Go to [complete reference](https://biscolab.com/google-maps-php-reference/) or read [documentation](https://gmaps-php-docs.biscolab.com/)

Google Maps Services
--------------------

[](#google-maps-services)

### Ready

[](#ready)

- Geocoding ☑️
- Elevation ☑️
- Places ☑️
- Time Zone ☑️

### ASAP

[](#asap)

- Directions (soon)
- Distance Matrix (soon)
- Road (soon)

### Not scheduled

[](#not-scheduled)

- Geolocation (not scheduled)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require biscolab/google-maps-php-sdk
```

Examples
--------

[](#examples)

Watch the [examples](https://github.com/biscolab/google-maps-php-sdk/tree/master/examples)

License
-------

[](#license)

[![MIT License](https://camo.githubusercontent.com/bca76d6ef684f1d4e0cbe1da9d4da9cbf8d37a16719d4bfed2d69ea9ec6c18ad/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f626973636f6c61622f676f6f676c652d6d6170732d7068702d73646b2e737667)](https://github.com/biscolab/google-maps-php-sdk/blob/master/LICENSE)

Documentation
-------------

[](#documentation)

This provide simple functions to work with Google Maps APIs. You can find further informations in [Google Maps Platform Documentation](https://developers.google.com/maps/documentation/)

Reference
---------

[](#reference)

You can find [complete API references](https://biscolab.com/google-maps-php-reference/)

Google Maps Services
--------------------

[](#google-maps-services-1)

### Ready

[](#ready-1)

- [Geocoding](/docs/geocoding)
- [Elevation](/docs/elevation) (Positional and Sampled Path Requests)
- [Places](/docs/places) (Search and Details)
- [Time Zone](/docs/timezone)

### ASAP

[](#asap-1)

- Directions (soon)
- Distance Matrix (soon)
- Road (soon)

### Not scheduled

[](#not-scheduled-1)

- Geolocation (not scheduled)

System requirements
-------------------

[](#system-requirements)

PHP 7.1 or greater

Composer
--------

[](#composer)

Install the package via composer:

```
composer require biscolab/google-maps-php-sdk
```

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](https://cloud.google.com/maps-platform/pricing/)
2. [Create your project](https://cloud.google.com/maps-platform/) by clicking on "Get started"
3. Create project credentials
4. Enable services (Geocoding API, Elevation API, etc...)

Google Console
--------------

[](#google-console)

[Google Console main page](https://console.cloud.google.com/)

Geocoding API
=============

[](#geocoding-api)

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

[Official Google Geocoding documentation](https://developers.google.com/maps/documentation/geocoding/start)

Initialize Geocoding Object
---------------------------

[](#initialize-geocoding-object)

First of all replace `YOUR_API_KEY` with your actual API key.

```
use Biscolab\GoogleMaps\Api\Geocoding;
use Biscolab\GoogleMaps\Enum\GoogleMapsApiConfigFields;

$geocoding = new Geocoding([
	GoogleMapsApiConfigFields::KEY => 'YOUR_API_KEY'
]);
```

Get results
-----------

[](#get-results)

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

Go to complete [SDK reference](https://biscolab.com/google-maps-php-reference/Biscolab/GoogleMaps/Api/Geocoding.html)

### Geocoding (Latitude/Longitude Lookup) by address as string

[](#geocoding-latitudelongitude-lookup-by-address-as-string)

[Official Google documentation](https://developers.google.com/maps/documentation/geocoding/intro#geocoding)

`getByAddress` accept following arguments:

NameRequiredTypeDescriptionaddressyes`string`The street address or plus code that you want to geocoderegionno`string`The region code, specified as a ccTLD ("top-level domain") two-character value. More info [here](https://developers.google.com/maps/documentation/geocoding/intro#RegionCodes)```
$results = $geocoding->getByAddress('Insert your address here, city, postal code etc...');
```

Change response language using `setLanguage` method

> You can find the list of supported languages here:

```
// Set Spanish language
$results = $geocoding->setLanguage('es')->getByAddress('Insert your address here, city, postal code etc...');
```

### Reverse Geocoding (Address Lookup) by Location/LatLng object

[](#reverse-geocoding-address-lookup-by-locationlatlng-object)

[Official Google documentation](https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding)

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

```
$results = $geocoding->getByLatLng(new LatLng([
			LatLngFields::LAT => $lat,
			LatLngFields::LNG => $lng,
		]));

// Alias `getReverse` deprecated!!!
$results = $geocoding->getReverse(new LatLng([
			LatLngFields::LAT => $lat,
			LatLngFields::LNG => $lng,
		]));
```

Change response language using `setLanguage` method

> You can find the list of supported languages here:

```
// Set Spanish language
$results = $geocoding->setLanguage('es')->getByLatLng(new LatLng([
			LatLngFields::LAT => $lat,
			LatLngFields::LNG => $lng,
		]));

// Use the same way for getReverse (alias) method
```

### By Place ID as string

[](#by-place-id-as-string)

`getByPlaceId` accept as parameter the address the place ID.

```
$results = $geocoding->getByPlaceId('YOUR_PLACE_ID');
```

Use results
-----------

[](#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.

```
$number_of_results = $results->count();
```

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

```
$first_result = $results->first();
```

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

Method nameReturn Type`getAddressComponents()``Address``getFormattedAddress()``string``getGeometry()``Geometry``getPlaceId()``string``getTypes()``array`Elevation API
=============

[](#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:

- Positional Requests
- Sampled Path Requests

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](https://developers.google.com/maps/documentation/elevation/start)

Initialize Elevation Object
---------------------------

[](#initialize-elevation-object)

First of all replace `YOUR_API_KEY` with your actual API key.

```
use Biscolab\GoogleMaps\Api\Elevation;
use Biscolab\GoogleMaps\Enum\GoogleMapsApiConfigFields;

$elevation = new Elevation([
	GoogleMapsApiConfigFields::KEY => 'YOUR_API_KEY'
]);
```

Get results (Positional Requests)
---------------------------------

[](#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

[](#single-location-object)

Create a Location object using latitude and longitude.

```
// get results by single Location object
$locations = new Location([
	LatLngFields::LAT => 39.73915360,
	LatLngFields::LNG => -104.9847034,
]);
```

### Array of Location objects

[](#array-of-location-objects)

Using multiple Location objects inside an array

```
// or by multiple Location objects
$locations = [
	new Location([
		LatLngFields::LAT => 39.73915360,
		LatLngFields::LNG => -104.9847034,
	]),
	// ... more locations
	new Location([
		LatLngFields::LAT => 50.123,
		LatLngFields::LNG => 99.456,
	])
];
```

### Polyline encoded string

[](#polyline-encoded-string)

Encode a location using the [Encoded Polyline Algorithm Format](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)

```
// or by polyline
$locations = 'enc:gfo}EtohhU';
```

### Make API call

[](#make-api-call)

```
// make API call
$results = $elevation->getByLocations($locations);
```

Get results (Sampled Path Requests)
-----------------------------------

[](#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

[](#array-of-location-objects-1)

Using multiple Location objects inside an array

```
// or by multiple Location objects
$path = [
	new Location([
		LatLngFields::LAT => 39.73915360,
		LatLngFields::LNG => -104.9847034,
	]),
	// ... more locations
	new Location([
		LatLngFields::LAT => 50.123,
		LatLngFields::LNG => 99.456,
	])
];
```

### Polyline encoded string

[](#polyline-encoded-string-1)

Encode a location using the [Encoded Polyline Algorithm Format](https://developers.google.com/maps/documentation/elevation/intro#Paths)

```
// or by polyline
$path = 'enc:gfo}EtohhUxD@bAxJmGF';
```

### Make API call

[](#make-api-call-1)

```
// make API call
$samples = 5; // must be int > 0
$results = $elevation->getBySampledPath($path, $samples);
```

Use results
-----------

[](#use-results-1)

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.

```
$number_of_results = $results->count();
```

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

```
$first_result = $results->first();
```

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

Method nameReturn Type`getLocation()``Location``getElevation()``float``getResolution()``float`Places API
==========

[](#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](https://developers.google.com/places/web-service/search).

There are 3 types of request:

- Find Place requests
- Nearby Search requests
- Text Search requests

[Official Google Place documentation](https://developers.google.com/places/web-service/search)

Initialize Places Object
------------------------

[](#initialize-places-object)

First of all replace `YOUR_API_KEY` with your actual API key.

```
use Biscolab\GoogleMaps\Api\Places;
use Biscolab\GoogleMaps\Enum\GoogleMapsApiConfigFields;

$place = new Places([
	GoogleMapsApiConfigFields::KEY => 'YOUR_API_KEY'
]);
```

Find Places requests
--------------------

[](#find-places-requests)

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

### Using name or address

[](#using-name-or-address)

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

```
use Biscolab\GoogleMaps\Fields\GoogleMapsRequestFields;

// get results by place's name or address
$result = $places->findPlaceByText("Museum of Contemporary Art Australia");
```

`findPlaceByText` method accepts 3 arguments

NameTypeDescriptionDefault`$query``string`The address (or the name) specifying which place to search forRequired`$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

[](#using-phone-number)

Search place using the "phone number".

```
use Biscolab\GoogleMaps\Fields\GoogleMapsRequestFields;

// get results by place's phone number
$result = $places->findPlaceByPhoneNumber("+61293744000");
```

`findPlaceByPhoneNumber` method accepts 3 arguments

NameTypeDescriptionDefault`$number``string`The phone number specifying which place to search forRequired`$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
----------------------

[](#nearby-search-requests)

This function looks for places within a specified area.

### Using location &amp; radius

[](#using-location--radius)

```
use Biscolab\GoogleMaps\Object\Location;
use Biscolab\GoogleMaps\Fields\GoogleMapsRequestFields;

$location = new Location([
        LatLngFields::LAT => -33.8670522,
        LatLngFields::LNG => 151.1957362,
    ]);
$radius = 1000;

$result = $places->findNearbyPlaceByRadius($location, $radius);
```

`findNearbyPlaceByRadius` method accepts 3 arguments

NameTypeDescriptionDefault`$location``Location`must be instance of `Biscolab\GoogleMaps\Object\Location` classRequired`$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

[](#rank-by-distance)

```
use Biscolab\GoogleMaps\Object\Location;
use Biscolab\GoogleMaps\Fields\GoogleMapsRequestFields;

$location = new Location([
        LatLngFields::LAT => -33.8670522,
        LatLngFields::LNG => 151.1957362,
    ]);

// You MUST set at least one of following values
$params = [
    GoogleMapsRequestFields::KEYWORD => 'a keyword',
    GoogleMapsRequestFields::NAME => 'name of the place you are looking for',
    // Biscolab\GoogleMaps\Values\PlaceTypeValues enum class
    GoogleMapsRequestFields::TYPE => 'Type of the place you are looking for'
];

$result = $places->findNearbyPlaceByDistance($location, $params);
```

`findNearbyPlaceByDistance` method accepts 2 arguments

NameTypeDescriptionDefault`$location``Location`must be instance of `Biscolab\GoogleMaps\Object\Location` classRequired`$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
-------------------

[](#text-search-request)

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

### Search by query

[](#search-by-query)

```
use Biscolab\GoogleMaps\Fields\GoogleMapsRequestFields;

$query = "restaurants in Sydney";

$params = [
    ...
];

$result = $places->textSearch($query, $params);
```

`textSearch` method accepts 2 arguments

NameTypeDescriptionDefault`$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
---------------

[](#places-details)

```
use Biscolab\GoogleMaps\Fields\GoogleMapsRequestFields;

$place_id = "ChIJN1t_tDeuEmsRUsoyG83frY4";

$params = [
    ...
];

$result = $places->details($place_id, $params);
```

`details` method accepts 2 arguments

NameTypeDescriptionDefault`$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
-----------

[](#use-results-2)

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

### Current page

[](#current-page)

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

```
$number_of_results = $results->count();
```

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

```
$first_result = $results->first();
```

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

Method nameReturn 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

[](#next-result-page)

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

```
// getNextPage method checks if $result has "next page"
$next_page_result = $result->getNextPage();
```

Time Zone API
=============

[](#time-zone-api)

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

[Official Google TimeZone documentation](https://developers.google.com/maps/documentation/timezone/start)

Initialize TimeZone Object
--------------------------

[](#initialize-timezone-object)

First of all replace `YOUR_API_KEY` with your actual API key.

```
use Biscolab\GoogleMaps\Api\TimeZone;
use Biscolab\GoogleMaps\Enum\GoogleMapsApiConfigFields;

$timezone = new TimeZone([
	GoogleMapsApiConfigFields::KEY => 'YOUR_API_KEY'
]);
```

Get result
----------

[](#get-result)

Go to complete [SDK reference](https://biscolab.com/google-maps-php-reference/Biscolab/GoogleMaps/Api/TimeZone.html)

### By location and timestamp

[](#by-location-and-timestamp)

```
$result = $timezone->get($location, $timestamp, $language);
```

`get` accepts 3 arguments

NameRequestedTypeDescription`$location`YesBiscolab\\GoogleMaps\\Object\\LocationRepresents the location to look up`$timestamp`YesintegerThe 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`NostringThe language in which to return resultsUse result
----------

[](#use-result)

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

Method nameReturn Type`getDdstOffset()``int``getRawOffset()``int``getTimeZoneId()``string``getTimeZoneName()``string`

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 99.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~107 days

Recently: every ~196 days

Total

12

Last Release

1675d ago

PHP version history (2 changes)v0.1.0PHP &gt;=7.1.1

0.9.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9263090?v=4)[Roberto Belotti](/maintainers/biscolab)[@biscolab](https://github.com/biscolab)

---

Top Contributors

[![biscolab](https://avatars.githubusercontent.com/u/9263090?v=4)](https://github.com/biscolab "biscolab (177 commits)")[![pryznar](https://avatars.githubusercontent.com/u/3277536?v=4)](https://github.com/pryznar "pryznar (1 commits)")

---

Tags

elevationgeocodinggooglegooglemapsgooglemaps-apigooglemaps-sdkgeocodinggooglemapsplaceselevationroads

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/biscolab-google-maps-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/biscolab-google-maps-php-sdk/health.svg)](https://phpackages.com/packages/biscolab-google-maps-php-sdk)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M45](/packages/tencentcloud-tencentcloud-sdk-php)[skagarwal/google-places-api

Google Places Api

1903.3M10](/packages/skagarwal-google-places-api)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
