Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Filament Map Field Laravel Package

lbcdev/filament-map-field

Filament Map Field adds Leaflet-powered map components for Filament v3/v4: MapField and MapEntry to pick/display coordinates, plus MapBoundsField/Entry for rectangular areas. Supports reactive updates, separate lat/lng fields, and nested JSON paths.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Filament Integration: The package is designed specifically for Filament (v3/v4), leveraging its form and infolist ecosystems. This aligns well with Laravel-based admin panels where spatial data visualization is required (e.g., location-based CRUD operations).
  • Livewire Dependency: Relies on lbcdev-map (Livewire component), which introduces a dependency on Livewire’s reactivity model. This is non-disruptive if Livewire is already in use but adds complexity if not.
  • Spatial Data Support: Ideal for applications requiring geospatial features (e.g., real estate, logistics, or asset tracking) where maps are critical for data entry/visualization.

Integration Feasibility

  • Low-Coupling Design: Components (MapField, MapEntry, etc.) are modular and can be adopted incrementally without overhauling existing forms.
  • JSON/Nested Field Support: v1.1.0+ adds flexibility for nested attributes (e.g., ubicacion.latitud), reducing boilerplate for complex models.
  • Filament v3/v4 Agnostic: Backward-compatible between major versions, minimizing migration risk during Filament upgrades.

Technical Risk

  • Livewire Overhead: If Livewire isn’t already in the stack, adding it for this package may introduce unnecessary complexity. Evaluate whether alternatives (e.g., vanilla JS map libraries) are viable.
  • Map Service Dependencies: The underlying lbcdev-map likely uses external APIs (e.g., Google Maps, OpenStreetMap). Ensure compliance with usage terms and budget for API costs.
  • State Management: Livewire’s reactivity may conflict with Filament’s form validation or workflows if not tested thoroughly. Validate edge cases (e.g., concurrent edits, form resets).
  • Performance: Heavy map interactions (e.g., zooming, markers) could impact UI responsiveness. Test with large datasets or high-traffic scenarios.

Key Questions

  1. Stack Compatibility:
    • Is Livewire already used in the project? If not, what’s the cost of adoption?
    • Are there existing map-related dependencies (e.g., Leaflet, Mapbox) that could conflict?
  2. Data Model Alignment:
    • How are coordinates currently stored (e.g., latitude/longitude columns, JSON fields)? Does the package’s nested field support reduce migration effort?
  3. API Constraints:
    • What map service is used (e.g., OpenStreetMap, Google Maps)? Are there licensing or cost implications?
  4. Testing Scope:
    • Are there Filament-specific edge cases (e.g., table actions, bulk operations) that need validation?
  5. Fallback Strategy:
    • What’s the plan if the map service fails (e.g., offline mode, degraded experience)?

Integration Approach

Stack Fit

  • Primary Use Case: Best suited for Filament-based admin panels where spatial data is central (e.g., user profiles with addresses, event locations).
  • Alternatives Considered:
    • Vanilla JS Libraries: If Livewire is avoided, libraries like Leaflet.js or Mapbox GL JS could be integrated directly, but would require custom form field wrappers.
    • Existing Laravel Packages: Packages like spatie/laravel-geocoder (for geocoding) or torann/laravel-geocoder (for reverse geocoding) could complement this for full spatial workflows.
  • Tech Stack Synergy:
    • Laravel 10/11/12: Native support ensures compatibility with Eloquent models and database storage.
    • Filament v3/v4: Native integration reduces boilerplate for form/infolist rendering.

Migration Path

  1. Assessment Phase:
    • Audit existing forms/infolists for spatial data fields (e.g., latitude, longitude, address).
    • Identify gaps (e.g., missing geocoding, area selection) where this package adds value.
  2. Proof of Concept:
    • Replace a simple text-based latitude/longitude form field with MapField in a non-critical resource.
    • Test JSON nested field support with a sample model (e.g., location->lat/lng).
  3. Incremental Rollout:
    • Phase 1: Replace basic coordinate inputs in forms (e.g., user profiles).
    • Phase 2: Add MapEntry to infolists for visualization (e.g., event listings).
    • Phase 3: Implement MapBoundsField for area-based selections (e.g., delivery zones).
  4. Validation:
    • Test form submission, validation, and database persistence.
    • Verify Livewire reactivity doesn’t interfere with Filament’s form lifecycle (e.g., save(), cancel()).

Compatibility

  • Filament Versions: Explicitly supports v3/v4 with no code changes required during upgrades.
  • PHP/Laravel: Requires PHP 8.1+, but Laravel 10/11/12 are fully supported.
  • Database: Assumes standard numeric columns for coordinates (e.g., decimal(10,8) for lat/lng). JSON fields are optional but recommended for nested data.
  • Dependencies:
    • Livewire: Must be installed (composer require livewire/livewire).
    • lbcdev-map: Auto-installed via package dependency (lbcdev/filament-map-field pulls in lbcdev-map).

Sequencing

  1. Prerequisites:
    • Install Livewire and the package:
      composer require livewire/livewire lbcdev/filament-map-field
      
    • Publish package config (if needed) and update config/filament.php.
  2. Configuration:
    • Set up map service API keys (e.g., Google Maps) in .env.
    • Configure default map options (e.g., zoom level, center) in the package config.
  3. Implementation:
    • Replace text inputs with MapField in Filament form definitions:
      use Lbcdev\FilamentMapField\Fields\MapField;
      
      MapField::make('coordinates')
          ->columnSpanFull()
          ->latitude('latitude')
          ->longitude('longitude');
      
    • Add MapEntry to infolists for visualization:
      use Lbcdev\FilamentMapField\Columns\MapEntry;
      
      MapEntry::make('coordinates')
          ->latitude('latitude')
          ->longitude('longitude');
      
  4. Post-Deployment:
    • Monitor Livewire component logs for errors (e.g., API failures).
    • Optimize map performance (e.g., lazy-loading, clustering markers).

Operational Impact

Maintenance

  • Package Updates:
    • Monitor lbcdev/filament-map-field and lbcdev-map for breaking changes. The MIT license allows forks if maintenance stalls.
    • Dependencies (Livewire, Filament) are actively maintained, reducing risk.
  • Customization:
    • Override default views or styles via Filament’s theming system or by publishing package assets.
    • Extend functionality by subclassing components (e.g., custom marker icons).
  • Debugging:
    • Livewire’s reactivity can obscure issues. Use wire:log or browser dev tools to trace component state.
    • Filament’s filament.log may capture errors related to form submission.

Support

  • Community:
    • Limited stars/dependents suggest low community support. Plan for self-support or internal documentation.
    • GitHub issues may be slow to respond; prioritize testing and fallback strategies.
  • Vendor Lock-in:
    • Tight coupling to lbcdev-map could make future swaps difficult. Document dependencies clearly for onboarding.
  • User Training:
    • End users may need guidance on map interactions (e.g., selecting points, drawing bounds). Include tooltips or in-app tutorials.

Scaling

  • Performance:
    • Marker Load: Large datasets may slow rendering. Implement pagination or clustering (e.g., via lbcdev-map options).
    • API Throttling: Map service APIs (e.g., Google Maps) have usage limits. Cache responses or use a CDN.
    • Database: Ensure coordinate columns are indexed for spatial queries (e.g., spatial index in PostgreSQL).
  • Concurrency:
    • Livewire’s server-side rendering can handle moderate traffic, but high concurrency may require:
      • Queueing map-related tasks (e.g., geocoding).
      • Caching frequent map interactions (e.g., static maps for infolists).
  • Horizontal Scaling:
    • Livewire components are stateless; scaling the Laravel app horizontally should not break map functionality, but session handling (e.g., for user-specific maps) must be tested.

Failure Modes

Failure Scenario Impact Mitigation
Map service API failure Broken map rendering Fallback to static map images or disable interactive maps.
Livewire component errors Form/infolist corruption Graceful degradation (e.g., show coordinates as text if map fails).
Database schema mismatch Form validation errors Use Filament’s fillUsing() or model observers to normalize data.
High latency in map
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor