2017 © Pedro PelĂĄez
 

library google-datastructures

A PHP library providing common data structures to reflect data received from Google services.

image

markenwerk/google-datastructures

A PHP library providing common data structures to reflect data received from Google services.

  • Monday, July 18, 2016
  • by bonscho
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,699 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 8 Versions
  • 11 % Grown

The README.md

PHP Google Data Structures

SensioLabs Insight Code Climate Latest Stable Version Total Downloads License, (*1)

A PHP library to query Google's Places service for querying locations and addresses and getting details by Places ID., (*2)

Installation

```{json} { "require": { "chroma-x/google-datastructures": "*" } }, (*3)


## Usage ### Autoloading and namesapce ```{php} require_once('path/to/vendor/autoload.php');

GeoLocation data structures

Reading a Google Places or Google Geocoder result

See PHP Google Places Suite or PHP Google Geocoder for example libraries using these datastructures., (*4)

Attention: Plaese note that all getter methods on the GeoLocationAddress return a GeoLocationAddressComponent instance or null. For preventing calls on non-objects the GeoLocationAddress class provides methods to check whether the address components exists., (*5)

```{php} // Retrieving a query result as ChromaX\GooglePlacesSuite\GooglePlacesDetailResult instance $googlePlacesDetailQuery = new GooglePlacesDetailQuery(); $googlePlacesDetailQuery ->setApiKey($this->googlePlacesApiKey) ->query('GOOGLE_PLACES_ID'); $queryResult = $googlePlacesDetailQuery->getResult();, (*6)

// Retieving address information as ChromaX\GoogleDataStructure\GeoLocation\GeoLocationAddress if($queryResult->hasAddress()) {, (*7)

if ($queryResult->getAddress()->hasStreetName()) {
    // Returns 'Lornsenstraße'
    $addressStreetShort = $queryResult->getAddress()->getStreetName()->getShortName();
    // Returns 'Lornsenstraße'
    $addressStreetLong = $queryResult->getAddress()->getStreetName()->getLongName();
}

if ($queryResult->getAddress()->hasStreetNumber()) {
    // Returns '43'
    $addressStreetNumberShort = $queryResult->getAddress()->getStreetNumber()->getShortName();
    // Returns '43'
    $addressStreetNumberLong = $queryResult->getAddress()->getStreetNumber()->getLongName();
}

if ($queryResult->getAddress()->hasPostalCode()) {
    // Returns '24105'
    $addressPostalCodeShort = $queryResult->getAddress()->getPostalCode()->getShortName();
    // Returns '24105'
    $addressPostalCodeLong = $queryResult->getAddress()->getPostalCode()->getLongName();
}

if ($queryResult->getAddress()->hasCity()) {
    // Returns 'KI'
    $addressCityShort = $queryResult->getAddress()->getCity()->getShortName();
    // Returns 'Kiel'
    $addressCityLong = $queryResult->getAddress()->getCity()->getLongName();
}

if ($queryResult->getAddress()->hasArea()) {
    // Returns 'Ravensberg - Brunswik - DĂŒsternbrook'
    $addressAreaShort = $queryResult->getAddress()->getArea()->getShortName();
    // Returns 'Ravensberg - Brunswik - DĂŒsternbrook'
    $addressAreaLong = $queryResult->getAddress()->getArea()->getLongName();
}

if ($queryResult->getAddress()->hasProvince()) {
    // Returns 'SH'
    $addressProvinceShort = $queryResult->getAddress()->getProvince()->getShortName();
    // Returns 'Schleswig-Holstein'
    $addressProvinceLong = $queryResult->getAddress()->getProvince()->getLongName();
}

if ($queryResult->getAddress()->hasCountry()) {
    // Returns 'DE'
    $addressCountryShort = $queryResult->getAddress()->getCountry()->getShortName();
    // Returns 'Germany'
    $addressCountryLong = $queryResult->getAddress()->getCountry()->getLongName();
}

}, (*8)

// Retieving address information as ChromaX\GoogleDataStructure\GeoLocation\GeoLocationGeometry if ($queryResult->hasGeometry()) {, (*9)

if ($queryResult->getGeometry()->hasLocation()) {
    // Returns 54.334123
    $geometryLocationLatitude = $queryResult->getGeometry()->getLocation()->getLatitude();
    // Returns 10.1364007
    $geometryLocationLatitude = $queryResult->getGeometry()->getLocation()->getLongitude();
}

if ($queryResult->getGeometry()->hasViewport()) {
    // Returns 54.335471980291
    $geometryLocationLatitude = $queryResult->getGeometry()->getViewport()->getNortheast()->getLatitude();
    // Returns 10.137749680292
    $geometryLocationLatitude = $queryResult->getGeometry()->getViewport()->getNortheast()->getLongitude();
    // Returns 54.332774019708
    $geometryLocationLatitude = $queryResult->getGeometry()->getViewport()->getSouthwest()->getLatitude();
    // Returns 10.135051719708
    $geometryLocationLatitude = $queryResult->getGeometry()->getViewport()->getSouthwest()->getLongitude();
}

if ($queryResult->getGeometry()->hasAccessPoints()) {
    for ($i = 0; $i < $queryResult->getGeometry()->countAccessPoints(); $i++) {
        // Returns 54.335471980291
        $geometryAccessPointLatitude = $queryResult->getGeometry()->getAccessPointAt($i)->getLatitude();
        // Returns 10.137749680292
        $geometryAccessPointLatitude = $queryResult->getGeometry()->getAccessPointAt($i)->getLongitude();
    }
}

}, (*10)

if ($queryResult->hasGooglePlacesId()) { // Retrieving the Google Places information from the query result // Returns 'ChIJ_zNzWmpWskcRP8DWT5eX5jQ' $googlePlacesId = $queryResult->getGooglePlacesId(); } ```, (*11)

Contribution

Contributing to our projects is always very appreciated.
But: please follow the contribution guidelines written down in the CONTRIBUTING.md document., (*12)

License

PHP Google Places Suite is under the MIT license., (*13)

The Versions

18/07 2016

dev-master

9999999-dev http://markenwerk.net/

A PHP library providing common data structures to reflect data received from Google services.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

google data structure

15/07 2016

2.0.1

2.0.1.0 http://markenwerk.net/

A PHP library providing common data structures to reflect data received from Google services.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

google data structure

11/07 2016

2.0.0

2.0.0.0 http://markenwerk.net/

A PHP library providing common data structures to reflect data received from Google services.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

google data structure

25/04 2016

1.0.1

1.0.1.0 http://markenwerk.net/

A PHP library providing common data structures to reflect data received from Google services.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

google data structure

25/04 2016

1.0

1.0.0.0 http://markenwerk.net/

A PHP library providing common data structures to reflect data received from Google services.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

google data structure

25/04 2016

0.1.2

0.1.2.0 http://markenwerk.net/

A PHP library providing common data structures to reflect data received from Google services.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

google data structure

25/04 2016

0.1.1

0.1.1.0 http://markenwerk.net/

A PHP library providing common data structures to reflect data received from Google services.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

google data structure

25/04 2016

0.1

0.1.0.0 http://markenwerk.net/

A PHP library providing common data structures to reflect data received from Google services.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

google data structure