PHPackages                             diogogpinto/filament-geolocate-me - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. diogogpinto/filament-geolocate-me

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

diogogpinto/filament-geolocate-me
=================================

Filament Geolocate Me

v0.1.1(1y ago)51.2k2[1 issues](https://github.com/diogogpinto/filament-geolocate-me/issues)MITPHPPHP ^8.1

Since Feb 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/diogogpinto/filament-geolocate-me)[ Packagist](https://packagist.org/packages/diogogpinto/filament-geolocate-me)[ Docs](https://github.com/diogogpinto/filament-geolocate-me)[ GitHub Sponsors](https://github.com/diogogpinto)[ RSS](/packages/diogogpinto-filament-geolocate-me/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (12)Versions (3)Used By (0)

Filament Geolocate Me
=====================

[](#filament-geolocate-me)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c337526724f9391f25adc7d4df4318c8ae0cd8129e2ee5684275ead025616092/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64696f676f6770696e746f2f66696c616d656e742d67656f6c6f636174652d6d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/diogogpinto/filament-geolocate-me)[![GitHub Tests Action Status](https://camo.githubusercontent.com/4405d57b707e6b647fedd5113e0c8336c6605c5b0d54e0dd56846aa9a8c5a09f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64696f676f6770696e746f2f66696c616d656e742d67656f6c6f636174652d6d652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/diogogpinto/filament-geolocate-me/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/67fbb45fef799fba9a4fc026b4b0988dfdc0a1b936f20fcc600a7fe3b5f1e213/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64696f676f6770696e746f2f66696c616d656e742d67656f6c6f636174652d6d652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/diogogpinto/filament-geolocate-me/actions?query=workflow%3A%22Fix+PHP+code+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/ab7546f56f56cb6d35e8901ef17d5d574e33862972faefffcdeb10b18d41274d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64696f676f6770696e746f2f66696c616d656e742d67656f6c6f636174652d6d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/diogogpinto/filament-geolocate-me)

Want to get a user's location before an Action is performed on Filament?
------------------------------------------------------------------------

[](#want-to-get-a-users-location-before-an-action-is-performed-on-filament)

This Filament plugin adds geolocation capabilities to your Filament Actions, allowing you to easily capture and use a user's geographic location. Also, it's plug and play! 🚀

- 🎯 Gets real-time user location with browser's Geolocation API
- ⚡ Halts action execution until location is captured
- 🔄 Automatically disables other actions while waiting
- 🛠 Injects location data into `before()`, `action()`, and `after()` methods
- 🔒 Built-in validation and error handling
- 📦 Zero configuration required - works out of the box
- 🎨 Filament-Native Experience

[![](art/screencast.gif)](art/screencast.gif)

Navigation
----------

[](#navigation)

- [Filament Geolocate Me](#filament-geolocate-me)
    - [Installation](#installation)
    - [Usage](#usage)
        - [Basic Usage](#basic-usage)
        - [Error Handling](#error-handling)
        - [Action Lifecycle](#action-lifecycle)
        - [Coordinates Data Structure](#coordinates-data-structure)
        - [Validation](#validation)
        - [Custom Styling](#custom-styling)
    - [Requirements](#requirements)
    - [Browser Support](#browser-support)
    - [Security](#security)
    - [Production Usage Warning](#production-usage-warning)
    - [Examples](#examples)
        - [Basic Check-in System](#basic-check-in-system)
    - [Credits](#credits)
    - [License](#license)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require diogogpinto/filament-geolocate-me
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Import the HasGeolocation trait in the Livewire component where your Filament Action is and add geolocation to any Filament action using the `withGeolocation()` method:

```
use Filament\Actions\Action;
use DiogoGPinto\GeolocateMe\Data\Coordinates;

//Import the HasGeolocation trait
use HasGeolocation;

Action::make('checkIn')
    ->withGeolocation()
    ->action(function (Coordinates $coordinates) {
        // Handle the location data in your action
        $latitude = $coordinates->latitude;
        $longitude = $coordinates->longitude;
        $accuracy = $coordinates->accuracy; // in meters, optional
    });
    ->before(function (Coordinates $coordinates) {
        // Do something with location data before running the action
    });
    ->after(function (Coordinates $coordinates) {
        // Do something with location data after running the action
    });
```

Caution

This plugin only works with custom Filament Actions. It is NOT compatible with Filament's prebuilt actions (like EditAction, CreateAction, etc.)

Tip

Location data (Coordinates) can be accessed in three action phases: before, action and after.

### Error Handling

[](#error-handling)

The plugin automatically handles geolocation errors. You can check for errors in your action:

```
Action::make('checkIn')
    ->withGeolocation()
    ->action(function (Coordinates $coordinates) {
        if ($coordinates->hasError()) {
            // Handle error case
            $errorMessage = $coordinates->error;
            return;
        }

        // Process location data
    });
```

### Action Lifecycle

[](#action-lifecycle)

The geolocation process follows this sequence:

1. Action is triggered and immediately halted
2. All other actions are temporarily disabled until the location process finishes
3. Browser requests location permission
4. Filament waits for location from Alpine
5. Loading state is shown
6. Location is captured and the action is fired
7. Action is executed with location data injected

### Coordinates Data Structure

[](#coordinates-data-structure)

The `Coordinates` class provides the following properties:

```
$coordinates->latitude;   // float: -90 to 90
$coordinates->longitude;  // float: -180 to 180
$coordinates->accuracy;   // float|null: accuracy in meters
$coordinates->error;      // string|null: error message if something went wrong
```

### Validation

[](#validation)

The plugin automatically validates coordinates to ensure they are within valid ranges:

- Latitude: -90 to 90 degrees
- Longitude: -180 to 180 degrees

### Custom Styling

[](#custom-styling)

The plugin uses Filament's default loading indicators. You can customize the appearance through Filament's theming system.

Examples
--------

[](#examples)

### Basic Check-in System

[](#basic-check-in-system)

```
use DiogoGPinto\GeolocateMe\Data\Coordinates;

Action::make('checkIn')
    ->withGeolocation()
    ->action(function (Coordinates $coordinates) {
        //Handle Error - if you can't locate the user, do nothing
        if ($location->hasError()) {
            Notification::make()
                ->danger()
                ->title('Error retrieving location')
                ->body($location->error)
                ->send();

            return;
        }

        //Create a checkin
        CheckIn::create([
            'latitude' => $coordinates->latitude,
            'longitude' => $coordinates->longitude,
            'accuracy' => $coordinates->accuracy,
            'user_id' => auth()->id(),
        ]);

        Notification::make()
            ->success()
            ->title('Checked in successfully')
            ->send();
    });
```

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.0 or higher
- FilamentPHP 3.0 or higher
- Browser with Geolocation API support

Browser Support
---------------

[](#browser-support)

This plugin relies on the [Geolocation API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API), which is supported by all modern browsers. Users will need to grant location permissions for the feature to work.

Security
--------

[](#security)

The plugin handles location data on the client side only when explicitly requested through an action. All coordinate validation is performed server-side to ensure data integrity.

Production Usage Warning
------------------------

[](#production-usage-warning)

Caution

This plugin is currently in its early stages (v0.1) and should be used with caution in production environments. While it has been tested in basic scenarios, it may contain bugs or unexpected behaviors. We recommend:

1. Thoroughly testing the plugin in your specific use case
2. Having proper error handling in place
3. Testing across different browsers and devices
4. Having a fallback mechanism in case of geolocation failures
5. Monitoring for any issues in production
6. Keeping the plugin updated for security patches and improvements

Please report any issues or suggestions on our [GitHub Issues](https://github.com/diogogpinto/filament-geolocate-me/issues) page.

Credits
-------

[](#credits)

- [Diogo Pinto](https://github.com/diogogpinto)
- [Geridoc](https://www.geridoc.pt) &amp; [Geribox](https://www.geribox.pt) for allowing me to release our packages with Open Source licenses
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 90.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

506d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/54b4f8f3cd85d6caa1276d4ef844851e34530fedcd92ec1082ef665ec95d6d9d?d=identicon)[diogogpinto](/maintainers/diogogpinto)

---

Top Contributors

[![diogogpinto](https://avatars.githubusercontent.com/u/74505947?v=4)](https://github.com/diogogpinto "diogogpinto (20 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

filamentfilament-pluginfilamentphpfilamentphp-pluginlaravellaravelfilamentdiogogpintofilament-geolocate-me

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/diogogpinto-filament-geolocate-me/health.svg)

```
[![Health](https://phpackages.com/badges/diogogpinto-filament-geolocate-me/health.svg)](https://phpackages.com/packages/diogogpinto-filament-geolocate-me)
```

###  Alternatives

[ysfkaya/filament-phone-input

A phone input component for Laravel Filament

3161.3M25](/packages/ysfkaya-filament-phone-input)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[stephenjude/filament-feature-flags

Filament implementation of feature flags and segmentation with Laravel Pennant.

122177.8k1](/packages/stephenjude-filament-feature-flags)[stephenjude/filament-jetstream

A Laravel starter kit built with Filament inspired by Jetstream.

17760.2k3](/packages/stephenjude-filament-jetstream)[stephenjude/filament-two-factor-authentication

Filament Two Factor Authentication: Google 2FA + Passkey Authentication

84215.9k9](/packages/stephenjude-filament-two-factor-authentication)[marcelweidum/filament-passkeys

Use passkeys in your filamentphp app

6649.5k1](/packages/marcelweidum-filament-passkeys)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
