{"id":15308190,"url":"https://github.com/yidas/google-maps-services-php","last_synced_at":"2025-04-05T18:09:48.864Z","repository":{"id":32865674,"uuid":"144558642","full_name":"yidas/google-maps-services-php","owner":"yidas","description":"PHP client library (SDK) for Google Maps API Web Services","archived":false,"fork":false,"pushed_at":"2024-03-24T11:43:37.000Z","size":47,"stargazers_count":72,"open_issues_count":1,"forks_count":34,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-29T17:09:39.014Z","etag":null,"topics":["google-maps-api-php","google-maps-sdk","google-maps-services","php","php-client"],"latest_commit_sha":null,"homepage":"https://yidas.github.io/google-maps-services-php/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yidas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-13T09:35:15.000Z","updated_at":"2025-02-27T10:18:01.000Z","dependencies_parsed_at":"2024-02-29T02:44:03.676Z","dependency_job_id":"714ce25f-5316-4fe7-9fe7-13a7da86edda","html_url":"https://github.com/yidas/google-maps-services-php","commit_stats":{"total_commits":10,"total_committers":2,"mean_commits":5.0,"dds":0.09999999999999998,"last_synced_commit":"870609e3917940a400f52629035cf441f2edc320"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidas%2Fgoogle-maps-services-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidas%2Fgoogle-maps-services-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidas%2Fgoogle-maps-services-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidas%2Fgoogle-maps-services-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yidas","download_url":"https://codeload.github.com/yidas/google-maps-services-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378149,"owners_count":20929297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google-maps-api-php","google-maps-sdk","google-maps-services","php","php-client"],"created_at":"2024-10-01T08:14:26.118Z","updated_at":"2025-04-05T18:09:48.835Z","avatar_url":"https://github.com/yidas.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://cloud.google.com/maps-platform/\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://cloud.google.com/images/maps-platform/google-maps-lockup.svg\" width=\"300px\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eGoogle Maps Services \u003ci\u003efor\u003c/i\u003e PHP\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\nPHP client library(SDK) for Google Maps API Web Services\n\n[![Latest Stable Version](https://poser.pugx.org/yidas/google-maps-services/v/stable?format=flat-square)](https://packagist.org/packages/yidas/google-maps-services)\n[![License](https://poser.pugx.org/yidas/google-maps-services/license?format=flat-square)](https://packagist.org/packages/yidas/google-maps-services)\n[![Total Downloads](https://poser.pugx.org/yidas/google-maps-services/downloads?format=flat-square)](https://packagist.org/packages/yidas/google-maps-services)\n[![Monthly Downloads](https://poser.pugx.org/yidas/google-maps-services/d/monthly?format=flat-square)](https://packagist.org/packages/yidas/google-maps-services)\n\n\nOUTLINE\n-------\n\n- [Demonstration](#demonstration)\n- [Description](#description)\n- [Requirements](#requirements)\n    - [API keys](#api-keys)\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Client](#client)\n        - [Google Maps APIs Premium Plan license](#google-maps-apis-premium-plan-license)\n        - [Language](#language)\n    - [APIs](#apis)\n\n---\n\nDEMONSTRATION\n-------------\n\n\n```php\n$gmaps = new \\yidas\\googleMaps\\Client(['key'=\u003e'Your API Key']);\n\n// Geocoding an address\n$geocodeResult = $gmaps-\u003egeocode('Taipei 101, Taipei City, Taiwan 110');\n\n// Look up an address with reverse geocoding\n$reverseGeocodeResult = $gmaps-\u003ereverseGeocode([25.0339639, 121.5644722]);\n\n// Request directions via public transit\n$directionsResult = $gmaps-\u003edirections('National Palace Museum', 'Taipei 101', [\n    'mode' =\u003e \"transit\",\n    'departure_time' =\u003e time(),\n    ]);\n```\n\n---\n\n\nDESCRIPTION\n-----------\n\nThe PHP Client for Google Maps Services is a PHP Client library for the following [Google Maps APIs](https://developers.google.com/maps):\n\n- Maps\n    - [Elevation API](#elevation-api) ([Google Doc](https://developers.google.com/maps/documentation/elevation/))\n- Routes\n    - [Routes API](#routes-api) ([Google Doc](https://developers.google.com/maps/documentation/routes))\n    - [Roads API](#roads-api) ([Google Doc](https://developers.google.com/maps/documentation/roads))\n    - [Directions API](#directions-api) ([Google Doc](https://developers.google.com/maps/documentation/directions/))\n    - [Distance Matrix API](#distance-matrix-api) ([Google Doc](https://developers.google.com/maps/documentation/distancematrix/))\n- Places\n    - [Places API] (TBD)\n    - [Geocoding API](#geocoding-api) ([Google Doc](https://developers.google.com/maps/documentation/geocoding/))\n    - [Geolocation API](#geolocation-api) ([Google Doc](https://developers.google.com/maps/documentation/geolocation/))\n    - [Time Zone API](#time-zone-api) ([Google Doc](https://developers.google.com/maps/documentation/timezone/))\n\n---\n\nREQUIREMENTS\n------------\n\n- PHP 7.0+ or higher\n\n### API keys\n\nEach Google Maps Web Service request requires an API key or client ID. API keys\nare freely available with a Google Account at\nhttps://developers.google.com/console. The type of API key you need is a\n**Server key**.\n\nTo get an API key:\n\n 1. Visit https://developers.google.com/console and log in with\n    a Google Account.\n 2. Select one of your existing projects, or create a new project.\n 3. Enable the Google Maps Services API(s) you plan to use, such as:\n    * Directions API\n    * Distance Matrix API\n    * Geocoding API\n    * ...\n 4. Create a new **Server key**.\n 5. If you'd like to restrict requests to a specific IP address, do so now.\n\nFor guided help, follow the instructions for the [Directions API][directions-key]. You only need one API key, but remember to enable all the APIs you need.\nFor even more information, see the guide to [API keys][apikey].\n\n**Important:** This key should be kept secret on your server.\n\n---\n\nINSTALLATION\n------------\n\nRun Composer in your project:\n\n    composer require yidas/google-maps-services\n\nThen you could call it after Composer is loaded depended on your PHP framework:\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse yidas\\googleMaps\\Client;\n```\n\n---\n\nUSAGE\n-----\n\nBefore using any Google Maps Services, first you need to create a Client with configuration, then use the client to access Google Maps Services.\n\n### Client\n\nCreate a Client using [API key]((#api-keys)):\n\n```php\n$gmaps = new \\yidas\\googleMaps\\Client(['key'=\u003e'Your API Key']);\n```\n\n#### Google Maps APIs Premium Plan license\n\nIf you use [Google Maps APIs Premium Plan license](https://developers.google.com/maps/documentation/directions/get-api-key#client-id) instead of an API key, you could create Client using client ID and client secret (digital signature) for authentication.\n\n```php\n$gmaps = new \\yidas\\googleMaps\\Client([\n    'clientID' =\u003e 'Your client ID',\n    'clientSecret' =\u003e 'Your digital signature'\n    ]);\n```\n\n#### Language\n\nYou could set language for Client for all services:\n\n```php\n$gmaps = new \\yidas\\googleMaps\\Client(['key'=\u003e'Your API Key', 'language'=\u003e'zh-TW']);\n```\n\n\u003e [list of supported languages - Google Maps Platform](https://developers.google.com/maps/faq#languagesupport)\n\nChanging language during execution:\n\n```php\n$gmaps-\u003esetLanguage('zh-TW');\n// ...\n```\n\n### APIs\n\n#### Elevation API\n\n[Elevation API overview | Google for Developers](https://developers.google.com/maps/documentation/elevation/overview)\n\n```php\n// Get elevation by locations parameter\n$elevationResult = $gmaps-\u003eelevation([25.0339639, 121.5644722]);\n$elevationResult = $gmaps-\u003eelevation('25.0339639, 121.5644722');\n```\n\n#### Routes API\n\n[Get a route | Google for Developers](https://developers.google.com/maps/documentation/routes/compute_route_directions)\n\n```php\n$routes = $gmaps-\u003ecomputeRoutes($originArray, $destinationArray, $fullBodyArray, $fieldMask)\n\n// Get the route data between two places simply\n$routes = $gmaps-\u003ecomputeRoutes([\n        \"location\" =\u003e [\n           \"latLng\" =\u003e [\n              \"latitude\" =\u003e 37.419734,\n              \"longitude\" =\u003e -122.0827784\n           ]\n        ]\n    ],\n    [\n        \"location\" =\u003e [\n           \"latLng\" =\u003e [\n              \"latitude\" =\u003e 37.41767,\n              \"longitude\" =\u003e -122.079595\n           ]\n        ]\n    ]);\n\n// Get the full route data between two places with full request data\n$routes = $gmaps-\u003ecomputeRoutes([...], [...], [\"travelMode\": \"DRIVE\", ...], '*');\n```\n\n#### Roads API\n\n[Snap to Roads  | Google for Developers](https://developers.google.com/maps/documentation/roads/snap)\n\n```php\n$roads = $gmaps-\u003esnapToRoads([[-35.27801,149.12958], [-35.28032,149.12907], [-35.28099,149.12929]]);\n```\n\n#### Directions API\n\n[Getting directions | Google for Developers](https://developers.google.com/maps/documentation/directions/get-directions)\n\n```php\n// Request directions via public transit\n$directionsResult = $gmaps-\u003edirections('National Palace Museum', 'Taipei 101', [\n    'mode' =\u003e \"transit\",\n    'departure_time' =\u003e time(),\n    ]);\n```\n\n\n#### Distance Matrix API\n\n[Get started with the Distance Matrix API | Google for Developers](https://developers.google.com/maps/documentation/distance-matrix/start)\n\n```php\n// Get the distance matrix data between two places\n$distanceMatrixResult = $gmaps-\u003edistanceMatrix('National Palace Museum', 'Taipei 101');\n\n// With Imperial units\n$distanceMatrixResult = $gmaps-\u003edistanceMatrix('National Palace Museum', 'Taipei 101', [\n    'units' =\u003e 'imperial',\n    ]);\n```\n\n#### Geocoding API\n\n[Geocoding API overview | Google for Developers](https://developers.google.com/maps/documentation/geocoding/overview)\n\n```php\n// Geocoding an address\n$geocodeResult = $gmaps-\u003egeocode('Taipei 101, Taipei City, Taiwan 110');\n\n// Look up an address with reverse geocoding\n$reverseGeocodeResult = $gmaps-\u003ereverseGeocode([25.0339639, 121.5644722]);\n```\n\n#### Geolocation API\n\n[Geolocation API overview | Google for Developers](https://developers.google.com/maps/documentation/geolocation/overview)\n\n```php\n// Simple geolocate\n$geolocateResult = $gmaps-\u003egeolocate([]);\n```\n\n#### Time Zone API\n\n[Time Zone API overview | Google for Developers](https://developers.google.com/maps/documentation/timezone/overview)\n\n```php\n// requests the time zone data for giving location\n$timezoneResult = $gmaps-\u003etimezone([25.0339639, 121.5644722]);\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyidas%2Fgoogle-maps-services-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyidas%2Fgoogle-maps-services-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyidas%2Fgoogle-maps-services-php/lists"}