- How do I install this package in a Laravel project with Filament v3?
- Run `composer require dotswan/filament-map-picker` to install the package. For Filament v3 specifically, use `composer require dotswan/filament-map-picker:"^1.8"` to ensure version compatibility. No additional Laravel setup is required beyond registering the field in your Filament resource.
- Does this package work with Filament v2 or only v3?
- This package explicitly supports **Filament v3 only**. If you're using Filament v2, this package will not work without modifications. Always check your `composer.json` constraints to avoid version conflicts.
- Can I use Google Maps or Mapbox instead of OpenStreetMap?
- The package currently supports **OpenStreetMap** by default. While you can customize tile layers via hooks, integrating Google Maps or Mapbox would require additional setup, including API keys and frontend configuration. The package is designed to be extensible for such use cases.
- How do I store the coordinates in my database?
- The package outputs coordinates as a `lat/lng` array or GeoJSON. Laravel Eloquent supports these natively—store them in a `json` column or separate `latitude`/`longitude` fields (e.g., `decimal(10,8)`). For GeoJSON, ensure your model uses `protected $casts = ['geojson_column' => 'array']`.
- Will this package work in production with high traffic?
- OpenStreetMap tiles are free but may throttle under heavy usage. For production, consider self-hosting tiles (e.g., TileServer GL) or caching. The package itself is lightweight, but test performance with your expected load, especially if using GeoMan’s vector editing tools.
- Can I customize the map controls or marker appearance?
- Yes, the package provides hooks and configuration options to customize controls, marker icons, and styling. For example, you can adjust the zoom level, disable default controls, or override the marker icon via the `Map::make()` method. Check the README for available options.
- Does this package support drawing polygons or complex shapes?
- Yes, the package integrates with **GeoMan**, allowing users to draw markers, polygons, polylines, and circles. You can enable GeoMan tools via configuration, but note that this increases bundle size (~500KB) and may require additional training for users unfamiliar with vector editing.
- How do I handle real-time coordinate updates when the marker moves?
- The package emits coordinates in real-time as the marker moves. These are stored in the field’s state and can be accessed via Filament’s `afterStateUpdated` callback. For dynamic forms, ensure your backend handles these updates efficiently, especially if validating or processing coordinates on the fly.
- Are there any alternatives to this package for Filament?
- Alternatives include `spatie/laravel-filament-map` (simpler, no GeoMan) or custom solutions using Leaflet.js directly. However, this package stands out for its **Filament v3 integration**, **GeoMan support**, and real-time coordinate updates. Evaluate whether you need advanced editing tools or just basic location selection.
- How do I test this package in my Laravel application?
- Start by adding the field to a Filament resource and testing in development. Mock map interactions (e.g., simulate marker drags) and verify coordinates are stored correctly. For frontend testing, ensure Leaflet.js and OpenStreetMap tiles load without conflicts. Use Laravel’s built-in testing tools for backend validation.