PHP code example of tareq-alqadi / filament-map-picker
1. Go to this page and download the library: Download tareq-alqadi/filament-map-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/ */
tareq-alqadi / filament-map-picker example snippets
namespace App\Filament\Resources;
use Filament\Resources\Resource;
use Filament\Resources\Forms\Form;
use Dotswan\MapPicker\Fields\Map;
...
class FilamentResource extends Resource
{
...
public static function form(Form $form)
{
return $form->schema([
Map::make('location')
->label('Location')
->columnSpanFull()
->afterStateUpdated(function (Get $get, Set $set, ?string $old, ?array $state): void {
$set('latitude', $state['lat']);
$set('longitude', $state['lng']);
})
->afterStateHydrated(function ($state, $record, Set $set): void {
$set('location', ['lat' => $record->latitude, 'lng' => $record->longitude]);
})
->liveLocation()
->showMarker()
->markerColor("#22c55eff")
->showFullscreenControl()
->showZoomControl()
->draggable()
->tilesUrl("http://tile.openstreetmap.de/{z}/{x}/{y}.png")
->zoom(15)
->extraTileControl([])
->extraControl([
'zoomDelta' => 1,
'zoomSnap' => 2,
])
]);
}
...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.