1. Go to this page and download the library: Download speniti/filament-mapbox 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/ */
speniti / filament-mapbox example snippets
public function form(Form $form): Form
{
return $form->schema([
Geocoder::make('address'),
]);
}
Geocoder::make('address')
// If true, the geocoder control will clear its contents and blur when the user presses the escape key (default true).
->clearAndBlurOnEsc(bool|Closure $clearAndBlurOnEsc = true)
// Limit the result to the specified countries.
->countries(string|array|Closure $countries)
// Like the one before but only one country.
->country(string|Closure $country)
// Specify whether the Geocoding API should attempt approximate, as well as exact, matching when performing searches (default true).
->fuzzyMatch(bool|Closure $fuzzyMatch = true)
// Limit the maximum number of results to show (default 5).
->limit(int|Closure $limit)
// Set the minimum number of characters to enter before results are shown (default 2).
->minLength(int|Closure $minLength)
// Set a list of types that filter results to match those specified.
->types(FeatureType|array|Closure $types)
public string $address = '';
public function form(Form $form): Form
{
return $form->schema([
Geocoder::make('address'),
]);
}
public function save(): void
{
$data = $this->form->getState();
// $address is a string containing the full address.
// $data['address'] is also a string containing the full address.
// e.g. "Times Square, New York, New York 10018, Stati Uniti d'America"
}
/** @var array<mixed> */
public array $address = [];
public function form(Form $form): Form
{
return $form->schema([
Geocoder::make('address'),
]);
}
public function save(): void
{
$data = $this->form->getState();
// $address is an associative array containing the address parts.
// $data['address'] is also an associative array containing the address parts.
// e.g. [
// address" => "Times Square"
// "street" => "Times Square"
// "postcode" => "10018"
// "place" => "New York"
// "region" => "New York"
// "country" => "Stati Uniti d'America"
// "placeName" => "Times Square, New York, New York 10018, Stati Uniti d'America"
// "coords" => array:2 [
// 0 => -73.98769
// 1 => 40.75534
// ]
//]
}
public AddressInfo $address;
public function mount(): void
{
$this->address = new AddressInfo();
}
public function form(Form $form): Form
{
return $form->schema([
Geocoder::make('address'),
]);
}
public function save(): void
{
$data = $this->form->getState();
// $address is an instance of AddressInfo containing the address parts.
// $data['address'] is also an instance of AddressInfo containing the address parts.
// e.g. Peniti\FilamentMapbox\Geocoder\AddressInfo {
// placeName: "Times Square, New York, New York 10018, Stati Uniti d'America"
// address: "Times Square"
// houseNumber: null
// street: "Times Square"
// postcode: "10018"
// place: "New York"
// region: "New York"
// country: "Stati Uniti d'America"
// coords: array:2 [
// 0 => -73.98769
// 1 => 40.75534
// ]
// }
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.