F
Filamentβ€’3w ago
nvK

Filament Google Maps plugin is not changing my TextInput fields when marker is being moved.

Hello there. I'm using this package. I'm working on a project that needs the latitude ang longitude so that we can put them up for people to navigate exactly where the place to go. My only problem is that when moving the marker using drag or click, The TextInput fields does not react. I tried reading the documentation a lot of times but it's not really working how I like it to work. It works when I: Move pin -> click on the text field for latitude -> click outside the text field -> the latitude and longitude updates
TextInput::make('lat')->label('Latitude Pin')
->nullable()
// ->hidden()
->maxLength(16)
>lazy(),
TextInput::make('lng')->label('Longitude Pin')
->nullable()
// ->hidden()
->maxLength(16)
->lazy(),
Map::make('location')
->columnSpanFull()
->height('600px')
->defaultZoom(15)
->draggable()
->reactive()
->afterStateUpdated(function ($state, callable $get, callable $set) {
$set('lat', $state['lat']);
$set('lng', $state['lng']);
}),
TextInput::make('lat')->label('Latitude Pin')
->nullable()
// ->hidden()
->maxLength(16)
>lazy(),
TextInput::make('lng')->label('Longitude Pin')
->nullable()
// ->hidden()
->maxLength(16)
->lazy(),
Map::make('location')
->columnSpanFull()
->height('600px')
->defaultZoom(15)
->draggable()
->reactive()
->afterStateUpdated(function ($state, callable $get, callable $set) {
$set('lat', $state['lat']);
$set('lng', $state['lng']);
}),
Only something works. Am I doing it wrong? I saw some posts like my problem in #google-maps but I can't seem to find the solution for that. Send help, my brother @cheesegrits Thanks!
Solution:
I just settled with mutating the data before saving and remove the fields from the form. πŸ‘
Jump to solution
3 Replies
toeknee
toekneeβ€’3w ago
did you add InteractsWithMaps on the EditRecord class as per the docs?
nvK
nvKOPβ€’3w ago
Yes, even with use InteractsWithMaps The fields are not changing in realtime. I just solved it with mutating the data before saving it in the database.
Solution
nvK
nvKβ€’3w ago
I just settled with mutating the data before saving and remove the fields from the form. πŸ‘

Did you find this page helpful?