{"id":22398747,"url":"https://github.com/tappnetwork/filament-google-autocomplete-field","last_synced_at":"2026-04-09T04:05:02.833Z","repository":{"id":248326509,"uuid":"826031211","full_name":"TappNetwork/filament-google-autocomplete-field","owner":"TappNetwork","description":"Filament plugin that provides an address autocomplete using Google Places autocomplete API, with fully customizable address fields.","archived":false,"fork":false,"pushed_at":"2025-09-09T18:08:44.000Z","size":1513,"stargazers_count":29,"open_issues_count":11,"forks_count":21,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-09-29T08:34:46.154Z","etag":null,"topics":["address","filament","google-autocomplete","php","plugin"],"latest_commit_sha":null,"homepage":"","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/TappNetwork.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"TappNetwork"}},"created_at":"2024-07-09T01:38:37.000Z","updated_at":"2025-09-09T18:08:48.000Z","dependencies_parsed_at":"2024-07-14T03:29:04.472Z","dependency_job_id":"49a84074-2524-4739-84d1-5b523b341bea","html_url":"https://github.com/TappNetwork/filament-google-autocomplete-field","commit_stats":null,"previous_names":["tappnetwork/filament-google-autocomplete-field"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/TappNetwork/filament-google-autocomplete-field","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2Ffilament-google-autocomplete-field","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2Ffilament-google-autocomplete-field/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2Ffilament-google-autocomplete-field/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2Ffilament-google-autocomplete-field/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TappNetwork","download_url":"https://codeload.github.com/TappNetwork/filament-google-autocomplete-field/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2Ffilament-google-autocomplete-field/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009076,"owners_count":26084549,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["address","filament","google-autocomplete","php","plugin"],"created_at":"2024-12-05T07:12:03.071Z","updated_at":"2025-10-11T22:52:02.654Z","avatar_url":"https://github.com/TappNetwork.png","language":"PHP","funding_links":["https://github.com/sponsors/TappNetwork"],"categories":[],"sub_categories":[],"readme":"# Filament Google Autcomplete Field\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/tapp/filament-google-autocomplete-field.svg?style=flat-square)](https://packagist.org/packages/tapp/filament-google-autocomplete-field)\n![GitHub Tests Action Status](https://github.com/TappNetwork/filament-google-autocomplete-field/actions/workflows/run-tests.yml/badge.svg)\n![GitHub Code Style Action Status](https://github.com/TappNetwork/filament-google-autocomplete-field/actions/workflows/fix-php-code-style-issues.yml/badge.svg)\n[![Total Downloads](https://img.shields.io/packagist/dt/tapp/filament-google-autocomplete-field.svg?style=flat-square)](https://packagist.org/packages/tapp/filament-google-autocomplete-field)\n\nThis plugin provides an address autocomplete using [Google Place autocomplete API](https://developers.google.com/maps/documentation/places/web-service/autocomplete), with fully customizable address fields.\n\n\u003e [!NOTE]\n\u003e The [Google Places API package](https://github.com/SachinAgarwal1337/google-places-api) is used to make API requests to Google Places.\n\n## Version Compatibility\n\n Filament | Filament Google Autocomplete Field\n:---------|:----------------------------------\n 3.x      | 1.x\n 4.x      | 4.x\n\n## Installation\n\nYou can install the package via Composer:\n\n### For Filament 3\n\n```bash\ncomposer require tapp/filament-google-autocomplete-field:\"^1.0\"\n```\n\n### For Filament 4\n\n```bash\ncomposer require tapp/filament-google-autocomplete-field:\"^4.0\"\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"filament-google-autocomplete-field-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n\n    'api-key' =\u003e env('GOOGLE_PLACES_API_KEY', ''),\n    'verify-ssl' =\u003e true,\n    'throw-on-errors' =\u003e false,\n\n];\n```\n\nOptionally, you can publish the translation files with:\n\n```bash\nphp artisan vendor:publish --tag=\"filament-google-autocomplete-field-translations\"\n```\n\n## Setup\n\nOn [Google console](https://console.cloud.google.com/apis/dashboard), create an application and enable the Places API.\n\n1. Click on \"ENABLE APIS AND SERVICES\"\n2. Search for \"Places api\"\n3. Click to enable it\n4. Get the API key\n\nIn your Laravel application, add the Google API key to `GOOGLE_PLACES_API_KEY` in your `.env` file:\n\n```php\nGOOGLE_PLACES_API_KEY=your_google_place_api_key_here\n```\n\n## Appareance\n\n![Filament Google Autcomplete Field](https://raw.githubusercontent.com/TappNetwork/filament-google-autocomplete-field/main/docs/autocomplete02.png)\n\n![Filament Google Autcomplete Field](https://raw.githubusercontent.com/TappNetwork/filament-google-autocomplete-field/main/docs/autocomplete03.png)\n\n![Filament Google Autcomplete Field](https://raw.githubusercontent.com/TappNetwork/filament-google-autocomplete-field/main/docs/autocomplete04.png)\n\n![Filament Google Autcomplete Field](https://raw.githubusercontent.com/TappNetwork/filament-google-autocomplete-field/main/docs/autocomplete05.png)\n\n![Filament Google Autcomplete Field](https://raw.githubusercontent.com/TappNetwork/filament-google-autocomplete-field/main/docs/autocomplete06.png)\n\n## Usage\n\nAdd the `GoogleAutocomplete` field to your form:\n\n```php\nuse Tapp\\FilamentGoogleAutocomplete\\Forms\\Components\\GoogleAutocomplete;\n\nGoogleAutocomplete::make('google_search'),\n```\n\nThis will use the default address fields and Google API options. You can also customize the address fields and Google Place API options. See all the options available on [`Available options`](#available-options) item below. For example:\n\n```php\nuse Tapp\\FilamentGoogleAutocomplete\\Forms\\Components\\GoogleAutocomplete;\n\nGoogleAutocomplete::make('google_search')\n    -\u003elabel('Google look-up')\n    -\u003ecountries([\n        'US',\n        'AU',\n    ])\n    -\u003elanguage('pt-BR')\n    -\u003ewithFields([\n        Forms\\Components\\TextInput::make('address')\n            -\u003eextraInputAttributes([\n                'data-google-field' =\u003e '{street_number} {route}, {sublocality_level_1}',\n            ]),\n        Forms\\Components\\TextInput::make('country'),\n        Forms\\Components\\TextInput::make('coordinates')\n            -\u003eextraInputAttributes([\n                'data-google-field' =\u003e '{latitude}, {longitude}',\n            ]),\n    ]),\n```\n\n### Using form layouts\n\nThe Google autocomplete fields can be wrapped in a Form layout like `Fieldset` or `Section`:\n\n```php\nForms\\Components\\Fieldset::make('Google Search')\n    -\u003eschema([\n        GoogleAutocomplete::make('google_search_field')\n        // ...\n    ]),\n```\n\n![Fieldset Layout](https://raw.githubusercontent.com/TappNetwork/filament-google-autocomplete-field/main/docs/fieldset_layout.png)\n\n```php\nForms\\Components\\Section::make('Google Search')\n    -\u003eschema([\n        GoogleAutocomplete::make('google_search_field')\n        // ...\n    ]),\n```\n\n![Section Layout](https://raw.githubusercontent.com/TappNetwork/filament-google-autocomplete-field/main/docs/section_layout.png)\n\n## Places API (original) and Places API (New)\n\nBoth the **[Places API (original)](https://developers.google.com/maps/documentation/places/web-service/autocomplete)** and the **[Places API (New)](https://developers.google.com/maps/documentation/places/web-service/place-autocomplete)** are supported.\nBy default, the Places API (original) it's used. To use the Places API (New) instead, add the `-\u003eplacesApiNew()` method, like so:\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003eplacesApiNew()\n```\n\n## Available Options\n\n### Autocompleted Fields\n\nYou can use the `withFields` method to define the fields that will be autocompleted.\n\nBy default the following fields are set if this method isn't provided:\n\n```php\nForms\\Components\\TextInput::make('address')\n    -\u003eextraInputAttributes([\n        'data-google-field' =\u003e '{street_number} {route}, {sublocality_level_1}',\n    ]),\nForms\\Components\\TextInput::make('city')\n    -\u003eextraInputAttributes([\n        'data-google-field' =\u003e 'locality',\n    ]),\nForms\\Components\\TextInput::make('country'),\nForms\\Components\\TextInput::make('zip')\n    -\u003eextraInputAttributes([\n        'data-google-field' =\u003e 'postal_code',\n    ]),\n```\n\nYou can override these default fields by passing an array of Filament form fields to `withFields` method:\n\n```php\nGoogleAutocompleteFields::make('google_search')\n    -\u003ewithFields([\n        Forms\\Components\\TextInput::make('address')\n            -\u003eextraInputAttributes([\n                'data-google-field' =\u003e '{street_number} {route}, {sublocality_level_1}',\n            ]),\n        Forms\\Components\\TextInput::make('city')\n            -\u003eextraInputAttributes([\n                'data-google-field' =\u003e 'locality',\n            ]),\n    ]),\n```\n\n#### Combining Fields\n\nYou can combine multiple fields returned by Google API in one field using curly braces `{}` to wrap the fields in `'data-google-field'` extra input attribute. For example, the `address` field below will contain the `street_number`, `route`, and `sublocality_level_1` and the `coordinates` field will contain the `latitude` and `longitude` fields:\n\n```php\nForms\\Components\\TextInput::make('address')\n    -\u003eextraInputAttributes([\n        'data-google-field' =\u003e '{street_number} {route}, {sublocality_level_1}',\n    ]),\nForms\\Components\\TextInput::make('coordinates')\n    -\u003eextraInputAttributes([\n        'data-google-field' =\u003e '{latitude},{longitude}',\n    ]),\n```\n\n#### Field Name\n\nIf your database field have a different name than the Google field (for example you DB field is `zip` and you want to use the Google's `postal_code` value returned by API), you can tie the API field to the DB field by passing your DB field name to `'data-google-field'` on `extraInputAttributes` method like so: \n\n```php\nForms\\Components\\TextInput::make('zip')\n    -\u003eextraInputAttributes([\n        'data-google-field' =\u003e 'postal_code',\n    ])\n```\n\nThese are the names of the Google metadata fields available to use:\n\n```\nstreet_number,\nroute,\nlocality,\nsublocality_level_1,\nadministrative_area_level_2,\nadministrative_area_level_1,\ncountry,\npostal_code,\nplace_id,\nformatted_address,\nformatted_phone_number,\ninternational_phone_number,\nname,\nwebsite,\nlatitude,\nlongitude,\n```\n\n#### long_name and short_name \n\nGoogle's Places API returns `long_name` and `short_name` values for address fields. You can choose which one to display by passing it to the `'data-google-value'` on `extraInputAttributes` method: \n\n```php\nForms\\Components\\TextInput::make('country')\n    -\u003eextraInputAttributes([\n        'data-google-value' =\u003e 'short_name',\n    ])\n```\n\nE.g. of `long_name` and `short_name` data returned by Google's API:\n\n```php\n\"street_number\" =\u003e [\n    \"long_name\" =\u003e \"1535\"\n    \"short_name\" =\u003e \"1535\"\n]\n\"route\" =\u003e [\n    \"long_name\" =\u003e \"Broadway\"\n    \"short_name\" =\u003e \"Broadway\"\n]\n\"locality\" =\u003e [\n    \"long_name\" =\u003e \"New York\"\n    \"short_name\" =\u003e \"New York\"\n]\n\"sublocality_level_1\" =\u003e [\n    \"long_name\" =\u003e \"Manhattan\"\n    \"short_name\" =\u003e \"Manhattan\"\n]\n\"administrative_area_level_2\" =\u003e [\n    \"long_name\" =\u003e \"New York County\"\n    \"short_name\" =\u003e \"New York County\"\n]\n\"administrative_area_level_1\" =\u003e [\n    \"long_name\" =\u003e \"New York\"\n    \"short_name\" =\u003e \"NY\"\n]\n\"country\" =\u003e [\n    \"long_name\" =\u003e \"United States\"\n    \"short_name\" =\u003e \"US\"\n] \n\"postal_code\" =\u003e [\n    \"long_name\" =\u003e \"10036\"\n    \"short_name\" =\u003e \"10036\"\n]    \n```\n\n### Autocomplete Field Column Span\n\nThe default column span for autcomplete select field is `'full'`. You can define other value (same as supported by Filament's `columnSpan()`) using the `autocompleteFieldColumnSpan` method:\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003eautocompleteFieldColumnSpan(1)\n```\n\n### Autocomplete Field Search Debounce\n\nThe default search debounce is 2 seconds to avoid too many requests to Google Places API. You can define other value using `autocompleteSearchDebounce` method:\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003eautocompleteSearchDebounce(1000) // 1 second\n```\n\n### Autocomplete Label\n\nThe label of the autocomplete select field can be modified using the `-\u003eautocompleteLabel()` method:\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003eautocompleteLabel('Select a location')\n```\n\n### Autocomplete Placeholder\n\nThe placeholder can be modified using the `-\u003eautocompletePlaceholder()` method:\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003eautocompletePlaceholder('Select a location')\n```\n\nExample with modified `label`, `autocompleteLabel`, and `autocompletePlaceholder`:\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003eautocompleteLabel('Select a location')\n    -\u003eautocompletePlaceholder('Click here to search')\n    -\u003elabel('Searching on Google...')\n    -\u003ecountries([\n        'us',\n        'au',\n    ])\n    -\u003eplaceTypes([\n        'book_store',\n        'cafe',\n    ])\n    -\u003ewithFields([\n        Forms\\Components\\TextInput::make('address')\n            -\u003eextraInputAttributes([\n                'data-google-field' =\u003e '{street_number} {route}, {sublocality_level_1}',\n            ]),\n        Forms\\Components\\TextInput::make('city')\n            -\u003eextraInputAttributes([\n                'data-google-field' =\u003e 'locality',\n            ]),\n    ]),\n```\n\n![Example with modified label, autocompleteLabel, and autocompletePlaceholder](https://raw.githubusercontent.com/TappNetwork/filament-google-autocomplete-field/main/docs/label_placeholder.jpg)\n\n## Google API Options\n\nThese following **Google API options** can be passed to the `GoogleAutocomplete` field:\n\n### OPTIONS FOR BOTH APIs\n\n### PlaceTypes\n\nRestrict the results to be of a certain type. Pass the [available types](https://developers.google.com/maps/documentation/places/web-service/supported_types) as an array:\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003eplaceTypes([\n        'lodging',\n        'book_store',\n        'florist',\n    ])\n```\n\nPlease refer to the [Google Places API original documentation](https://developers.google.com/maps/documentation/places/web-service/autocomplete#types) and [Google Places API New documentation](https://developers.google.com/maps/documentation/places/web-service/place-autocomplete#includedPrimaryTypes) to a detailed description of this option.\n\n### Language\n\nThe language which results should be returned. These are the [supported language codes](https://developers.google.com/maps/faq#languagesupport).\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003elanguage('pt-BR')\n```\n\n### Offset\n\nThe position, in the input term, of the last character that the service uses to match predictions. For example, if the input is Google and the offset is 3, the service will match on Goo. \n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003eoffset(5)\n```\n\n### LocationBias\n\nPrefer results in a specified area, by specifying either a radius plus lat/lng, or two lat/lng pairs representing the points of a rectangle. If this parameter is not specified, the API uses IP address biasing by default.\n\nPlease refer to the [Google Places API original documentation](https://developers.google.com/maps/documentation/places/web-service/autocomplete#locationbias) and [Google Places API New](https://developers.google.com/maps/documentation/places/web-service/place-autocomplete#location-bias-restriction) to a detailed description of this option.\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003elocationBias(\n        [\n            \"circle\" =\u003e [\n                \"center\" =\u003e [\n                    \"latitude\" =\u003e 37.7937,\n                    \"longitude\" =\u003e -122.3965\n                ],\n                \"radius\" =\u003e 500.0\n            ]\n        ]\n    )\n```\n\n### LocationRestriction\n\nRestrict results to a specified area, by specifying either a radius plus lat/lng, or two lat/lng pairs representing the points of a rectangle.\n\nPlease refer to the [Google Places API original documentation](https://developers.google.com/maps/documentation/places/web-service/autocomplete#locationrestriction) and [Google Places API New](https://developers.google.com/maps/documentation/places/web-service/place-autocomplete#location-bias-restriction) to a detailed description of this option.\n\n### Origin\n\nThe origin point as `latitude,longitude` from which to calculate straight-line distance to the destination specified.\n\nPlease refer to the [Google documentation](https://developers.google.com/maps/documentation/places/web-service/autocomplete#origin) to a detailed description of this option.\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003eorigin(40.7585862,-73.9858202)\n```\n\n### Region\n\nThe region code used to format the response, specified as a [country code top-level domain (ccTLD)](https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Country_code_top-level_domains) two-character value. \n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003eregion('uk')\n```\n\n### SessionToken\n\nRandom string which identifies an autocomplete session for billing purposes.\n\nPlease refer to the [Google documentation](https://developers.google.com/maps/documentation/places/web-service/autocomplete#sessiontoken) to a detailed description of this option.\n\n\n### OPTIONS ONLY FOR PLACES API (ORIGINAL)\n\n### Countries\n\nAdd the `countries` method to restrict the countries that should be used for autocomplete search.\n\nThe countries must be passed as a two character ISO 3166-1 Alpha-2 compatible country code. You can find the country codes available at [Wikipedia: List of ISO 3166 country codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003ecountries([\n        'US',\n        'AU',\n    ])\n```\n\n### Location\n\nThe point around which to retrieve place information as `latitude,longitude`.\n\nPlease refer to the [Google documentation](https://developers.google.com/maps/documentation/places/web-service/autocomplete#location) to a detailed description of this option.\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003elocation(40.7585862,-73.9858202)\n```\n\n### Radius\n\nThe distance in meters within which to return place results.\n\nPlease refer to the [Google documentation](https://developers.google.com/maps/documentation/places/web-service/autocomplete#radius) to a detailed description of this option.\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003eradius(10)\n```\n\n\n### OPTIONS ONLY FOR PLACES API (NEW)\n\n### IncludePureServiceAreaBusinesses\n\n`true` - includes businesses that visit or deliver to customers directly, but don't have a physical business location.\n`false` - returns only businesses with a physical business location.\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003eincludePureServiceAreaBusinesses(true)\n```\n\n### IncludedRegionCodes\n\nOnly include results from the list of specified regions, specified as an array of up to 15 ccTLD (\"top-level domain\") two-character values. When omitted, no restrictions are applied to the response.\n\n```php\nGoogleAutocomplete::make('google_search')\n    -\u003eincludedRegionCodes([\n        \"de\", \n        \"fr\",\n    ])\n```\n\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n-   [Tapp Network](https://github.com/TappNetwork)\n-   [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftappnetwork%2Ffilament-google-autocomplete-field","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftappnetwork%2Ffilament-google-autocomplete-field","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftappnetwork%2Ffilament-google-autocomplete-field/lists"}