Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geocomplete, lan, lon? #71

Open
robertpotkowa opened this issue Jan 2, 2024 · 2 comments
Open

Geocomplete, lan, lon? #71

robertpotkowa opened this issue Jan 2, 2024 · 2 comments

Comments

@robertpotkowa
Copy link

Is it possible to get lan, lon out of submitting the geocomplete field, instead the searched address?
I use the field as a standalone search inside a livewire component.

@Pronesti
Copy link

This is doing both reverse Geocode and setting lat and lng inputs on my form.

Geocomplete::make('address_1')
    ->reactive()
    ->types(['premise'])
    ->countries(['us'])
     ->reverseGeocode([
       'city'   => '%L',
        'zip_code'    => '%z',
        'state'  => '%A1',
        'address_1' => '%n %S',
    ])
    ->updateLatLng(),

@Alex92zz
Copy link

Alex92zz commented Jun 6, 2024

are you using php filament v2 or v3? I am using v3 and I have the same problem, doesn't update my "lat" and "lng" fields.

Strangely enough mine it works only if I click on the address multiple times.

For example if I drag the pin on the map for the first time or I search for an address it will update the "lng" and "lat" from the Map::make('location) using:

->afterStateUpdated(function ($state, callable $get, callable $set) {
                                        // This method is called every time the map marker is moved
                                        Log::info('afterStateUpdated from map: ' . json_encode($state));
                                        $set('lng', $state['lng']);
                                        $set('lat', $state['lat']);
                                    })

After this the ->afterStateUpdated() will not be called again, even if I drag and drop in another location.

But if I drag and drop in another location, the address will change in the Geocomplete::make('site_address') dropdown, I select the address and the "lng" and "lat" are not being changed, I click again on the input box, dropdown appears, I select again on the address showing up from "powered by Google", nothing happens again, when I do it 3th time somehow it triggers this ->updateLatLng() and it updates the "lat" and "lng".

And after it updates the "lat" and "lng" if I click again on the input box for the full_address the dropdown from the "powered by Google" doesn't appear anymore.


Another way to update the "lat" and "lng" on the first click is if I click on the ->geolocate() button. I don't need to click on this button multiple times to update the "lat" and "lng". I only click once and it works properly, I think something was implemented correctly for this function but not for ->updateLatLng().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants