dotswan/filament-map-picker
Filament v3 map picker field with OpenStreetMap integration. Let users select a location and get real-time coordinates when the marker moves. Customize controls and marker styling, with optional GeoMan tools for drawing and editing shapes.
Form and Infolist components. The package extends Filament’s field system without requiring invasive changes to the core application.Map::make()), reducing integration complexity.afterStateUpdated/afterStateHydrated, enabling seamless sync with database fields (e.g., latitude, longitude, geojson).fn ($record) => $record->latitude) allow runtime flexibility, critical for CRUD operations.json_encode/json_decode in afterStateUpdated). Edge cases (malformed GeoJSON) may need error handling.extraStyles to avoid layout shifts.geojson be stored as a JSON column in the database, or normalized into separate tables for large geometries?latitude/longitude (float) or geojson (JSON/TEXT). Recommended schema:
$table->decimal('latitude', 10, 8)->nullable();
$table->decimal('longitude', 11, 8)->nullable();
$table->json('geojson')->nullable(); // For GeoMan-generated data
LocationResource) to test basic marker functionality.afterStateUpdated logic for syncing latitude/longitude to the database.draggable(false) for read-only maps (e.g., Infolist) to reduce resource usage.minZoom/maxZoom constraints to limit bandwidth.^1.8). Avoid mixing with Filament v2.leaflet-geoman). Ensure no version conflicts with existing Leaflet usage.extraStyles may override Filament’s default styling. Use !important sparingly; prefer BEM classes.Map field to a form.geoMan(true) and validate vector editing UX.rangeSelectField with distance-based logic (e.g., "Show venues within 5km").boundaries work as expected (e.g., preventing selection outside a region).dotswan/filament-map-picker for breaking changes (e.g., GeoMan API updates).composer.json if using custom builds.extraStyles/markerIconUrl to avoid forks.tilesUrl and CORS for tile requests.afterStateUpdated logic and Set usage.wire:log for state updates.geoMan or reduce maxZoom if map rendering lags.latitude/longitude columns for spatial queries (e.g., ->whereRaw('ST_DWithin(..., POINT(longitude, latitude), 5000)')).liveLocation updates may increase database writes. Throttle with milliseconds or queue updates (e.g., Laravel Queues).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| OpenStreetMap tile provider down | Map tiles fail to load | Fallback to local tiles or user notification. |
| GeoMan JavaScript errors | Vector editing breaks | Feature flag GeoMan; provide fallback instructions. |
| Database connection issues | afterStateUpdated fails silently |
Add transaction retries or error boundaries. |
| Malformed GeoJSON data | Corrupted geometry storage | Validate GeoJSON on input (e.g., json_validate() in MySQL 8.0+). |
| Browser unsupported | Map renders incorrectly | Polyfill Leaflet.js or document minimum requirements. |
MapFieldUsage.md with examples for common use cases (e.g., "How to store GeoJSON").afterStateUpdated, defaultLocation, geoMan.How can I help you explore Laravel packages today?