PHP code example of erkurn / filament-address-picker

1. Go to this page and download the library: Download erkurn/filament-address-picker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

erkurn / filament-address-picker example snippets




class FilamentResource extends Resource
{
    public static function form(Form $form)
    {
        return $form->schema([
            AddressPicker::make('coordinate')
                ->setDefaultLocation([ // Set Default Location
                    'lat' =>    -6.914744,
                    'lng'  =>  107.609810
                ])
                ->mapControls([ // Map Controls
                    'mapTypeControl' => true,
                    'scaleControl' => true,
                    'streetViewControl' => false,
                    'rotateControl' => true,
                    'fullscreenControl' => true,
                    'searchBoxControl' => true
                ])
                ->minHeight(300) // Min Height In Pixels
                ->defaultZoom(16) // Default Zoom
                ->placeholder("Search Address") // Default Search
                ->afterStateUpdated(function ($state, $component, $set) {
                    $location = $component->getAddress(); // Get Details Location After Pick Location
                    
                    $location->getAdminLevels()->get(4)->getName(); // Post Code
                    $location->getStreetName(); // Street Name
                    $location->getStreetNumber(); // Street Number
                })
                ->placeholder("Search Address")
        ]);  
    }
}