erkurn/filament-address-picker

Pick Or Auto Complete Address For Filament Field

v1.1.3 2022-10-04 01:21 UTC

This package is auto-updated.

Last update: 2022-12-04 01:43:39 UTC


README

68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f46696c616d656e74253230416464726573732532305069636b65722e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d65726b75726e25324666696c616d656e742d616464726573732d7069636b6572267061747465726e3d616e63686f727341776179267374796c653d7374796c655f32266465736372697074696f6e3d476f6f676c652b4d61702b415049266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313235707826696d616765733d676c6f6265267769647468733d33303026686569676874733d333030

Pick Address For Filament Field

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A Filament Field to enable pick location in google map and return geo coordinates. For initial location you can use coordinate or address.

this packages require Google Map API and using this service :

  • Maps JavaScript API
  • Places API

Installation

You can install the package via composer:

composer require erkurn/filament-address-picker

Usage

<?php

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")
        ]);  
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.