So the value that would be rendered within the coordinates input would be something like: 39.3315476, -94.9363912 If you want to concatenate certain elements of the geocoded object that is returned by Google, using '), Or you can make the field invisible in the form but collect the data anyways AddressMetadata:: make( 'long')-> fromValue( 'longitude')-> invisible(), Combine Values You can disable the field so the user can't edit the metadata AddressMetadata:: make( 'long')-> fromValue( 'longitude')-> disabled(), And you can store the values by autocomplete like this AddressMetadata:: make( 'lat')-> fromValue( 'latitude'),ĪddressMetadata:: make( 'long')-> fromValue( 'longitude'), Now this address field will search and store the address as a string, but also made available the values in the withValues array GoogleAutocomplete:: make( 'Address')-> withValues(), Use EmilianoTisato\ GoogleAutocomplete\ GoogleAutocomplete 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 use EmilianoTisato\ GoogleAutocomplete\ AddressMetadata Specify multiple countries GoogleAutocomplete:: make( 'Address') Specify a single country GoogleAutocomplete:: make( 'Address') You can add a country or countries to autocomplete or leave empty for all. env file ADDRESS_AUTOCOMPLETE_API_KEY= # UsageĪdd the use declaration to your resource and use the fields: use EmilianoTisato\ GoogleAutocomplete\ GoogleAutocomplete Now publish config and localization files: php artisan vendor:publish -provider= "EmilianoTisato\GoogleAutocomplete\FieldServiceProvider "Ĭreate an app and enable Places API and create credentials to get your API keyĪdd the below to your. You can install the package in to a Laravel app that uses Nova via composer: composer require emilianotisato/nova-google-autocomplete-field 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).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |