Download the PHP package yieldstudio/nova-google-autocomplete without Composer
On this page you can find all versions of the php package yieldstudio/nova-google-autocomplete. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yieldstudio/nova-google-autocomplete
More information about yieldstudio/nova-google-autocomplete
Files in yieldstudio/nova-google-autocomplete
Package nova-google-autocomplete
Short Description A Laravel Nova Google autocomplete field.
License MIT
Homepage https://github.com/YieldStudio/nova-google-autocomplete
Informations about the package nova-google-autocomplete
Nova Google AutoComplete Field Package
This field allows you to work with Google Places API to autocomplete on user input and get the full real address with all the metadata (like latitude and longitude).
Fork from emilianotisato/nova-google-autocomplete-field to maintain package.
Installation
You can install the package in to a Laravel app that uses Nova via composer:
Now publish config and localization files:
Create an app and enable Places API and create credentials to get your API key https://console.developers.google.com
Add the below to your .env
file
Usage
Add the use declaration to your resource and use the fields:
You can access other parameter like latitude, longitude, street_number, route, locality, administrative_area_level_1, country, postal_code
, along with everything available in the - every field present in the PlaceResult object
By default, the formatted address will be stored on the property provided in the GoogleAutocomplete field. If you don't want to store it, you can use the dontStore
method:
Combine Values
If you want to concatenate certain elements of the geocoded object that is returned by Google, using {{
and }}
, wrap the key like you would above; like so:
So the value that would be rendered within the coordinates input would be something like:
Define Short/Long Value
If you would like to use the long_name version of the geocoded object (Kansas versus KS), you can define the GoogleAutocomplete
field values with dot notation followed with the name version you want to use; like so:
Which would return:
route: W 143rd St
administrative_area_level_1: Kansas
You can change the type of places that are returned by the autocomplete using the placeType() method. You can use any of the values listed at https://developers.google.com/places/supported_types#table3
Capturing all values as JSON
If you want to capture all requested values as a JSON object, you can use the fromValuesAsJson()
helper instead of using fromValue()
.
Localization
If you want this package in your language, just create a json lang file in your resources/lang/vendor/nova-google-autocomplete
folder.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.
Credits
- Emiliano Tisato - Original developer
- James Hemery - Fork maintainer
- Simon Depelchin - Contributor
License
The MIT License (MIT). Please see License File for more information.