heloufir / filament-leaflet-geosearch

Implementation of LeafLet GeoSearch as a Filament Form Field
MIT License
19 stars 6 forks source link

Generate Latitude and longitude when changed #3

Open gtresnandika opened 1 year ago

gtresnandika commented 1 year ago

public static function form(Form $form): Form { return $form ->schema([ Card::make() ->schema([ Forms\Components\TextInput::make('id') ->required() ->maxLength(2), Forms\Components\TextInput::make('name') ->required() ->maxLength(255), Card::make() ->schema([ LeafletInput::make('location') ->setMapHeight(300) // Here you can specify a map height in pixels, by default the height is equal to 200 ->setZoomControl(true) // Here you can enable/disable zoom control on the map (default: true) ->setScrollWheelZoom(true) ->setZoomLevel(3) // Here you can change the default zoom level (when the map is loaded for the first time), default value is 10 ->required() ->reactive() ->afterStateUpdated(function ($state, $set) { $result = json_encode($state); $obj = json_decode($result); $set('latitude', $obj->y); $set('longitude', $obj->x); }), ])->columns(1), Forms\Components\TextInput::make('latitude'), Forms\Components\TextInput::make('longitude'), ])->columns(2) ]); }