Download the PHP package eduardoribeirodev/filament-leaflet without Composer

On this page you can find all versions of the php package eduardoribeirodev/filament-leaflet. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filament-leaflet

Filament Leaflet

A powerful and elegant Leaflet integration for Filament PHP that makes creating interactive maps a breeze. Build beautiful, feature-rich maps with markers, clusters, shapes, and more using a fluent, expressive API.

🌟 Features

Table of Contents

Installation

Publish the assets:

This will publish the Leaflet assets used by the package.

Configuration

You can configure default values for the package in config/filament-leaflet.php:

Publish the configuration file:

For Mapbox tile layers, configure your access token in your environment or in config/services.php:

Core Components

Map Widget

Create your first interactive map widget:

Basic Configuration

Map Interaction Control

Control how users interact with your map:

Static Maps - Disable all interactions:

Controls

Enable/disable map controls:

Conditionally show controls at runtime:

Tile Layers

Choose from multiple providers or add custom layers:

Available providers: OpenStreetMap, GoogleStreets, GoogleSatellite, GoogleHybrid, GoogleTerrain, EsriWorldImagery, EsriWorldStreetMap, EsriNatGeo, CartoPositron, CartoDarkMatter, MapboxStreets, MapboxOutdoors, MapboxLight, MapboxDark, MapboxSatellite, MapboxSatelliteStreets, MapboxNavigationDay, MapboxNavigationNight

Mapbox Tile Layer:

To use Mapbox tiles, configure your access token in .env or config/services.php. Then use the Mapbox tile layer in your widget:

MapPicker (Form Field)

Add an interactive map inside Filament forms. It syncs map clicks to form fields and supports all MapWidget configuration methods.

Load GeoJSON: Automatically loads from models with HasGeoJsonFile trait or getGeoJsonUrl() method:

Customize pick marker: Visual feedback when clicking the map:

Dynamic configuration: Most methods accept closures:

GeoSearchInput (Form Field)

Search and select locations using multiple geocoding providers:

Advanced Configuration:

Form Model Integration:

New selections return a GeoSearchResult (or the selected label when textMode(true) is enabled). If your model uses the Coordinate cast, only latitude and longitude are stored. When editing that record, the field returns the saved Coordinate until another search result is selected, and displays latitude, longitude by default.

To display an address you have stored separately, configure a coordinate label resolver:

The callback can also receive Coordinate $coordinate through a parameter named $coordinate and call your application's reverse-geocoding service. Return a string label, or null to use the coordinate fallback. Reverse geocoding is opt-in: this package makes no automatic lookup when loading saved coordinates. Cache lookups in your callback, since label resolution may run more than once; handle provider failures by returning null. A reverse lookup may return a different label from the original search result.

The field returns a GeoSearchResult object containing:

Address Components:

The Address object provides structured address data:

MapColumn (Table Column)

Display maps directly in Filament table columns:

Display circular maps for a unique visual style:

MapEntry (Infolist)

Display read-only maps in Filament infolists:

Auto-recenter: Maps automatically recenter after 3 seconds when users pan around. This provides a guided viewing experience while allowing temporary exploration:

Map Elements

Markers

Creating Markers

Marker Icons

Markers support multiple icon types with different visual behaviors:

Custom Icon URL (replaces the entire marker):

When using a custom icon URL, the entire marker is replaced with your custom image - the marker's color is ignored.

Heroicons (Filament Icons) (icon in center):

When using Heroicons, the marker keeps its default styled appearance with the color gradient, and the Heroicon is automatically rendered in the center in white. The marker's color settings (.blue(), .red(), etc.) are fully respected.

Icon Appearance:

Marker Colors

Markers accept colors in multiple formats:

Using Color Class:

Using string formats:

Available convenience methods: blue(), red(), green(), orange(), yellow(), violet(), gray(), black(), gold(), randomColor()

From Eloquent Models

Note: The coordsColumn parameter expects a Coordinate value object. Configure your model like this:

Layer Groups

Layer groups are a powerful way to organize and manage multiple layers on your map. They allow you to:

Layer Group

A simple container for organizing related layers. Perfect for grouping logically related markers and shapes without any automatic behavior:

Using the group() helper method (shorthand):

Instead of wrapping layers in LayerGroup::make(), you can use the group() method on any layer to automatically group multiple layers:

Feature Group

Creates a polygon envelope around all layers in the group. This is useful for visualizing the coverage area or boundary of a set of points:

Marker Cluster

Groups nearby markers into clusters for better performance and visual clarity, especially with large datasets. Clusters automatically expand when zooming in:

Cluster from Model:

Create clusters directly from Eloquent models with powerful customization:

Cluster with Query Modification:

Filter and customize the query used to load markers:

Advanced cluster configuration:

Shapes

Draw various geometric shapes on your map:

Circles

Circles with radius in various units:

Circle Markers

Small circles with pixel-based radius (like markers but circular):

Polygons

Draw custom polygons:

Polylines

Draw lines connecting multiple points:

Rectangles

Draw rectangular bounds:

Shapes from Eloquent Models

All shape classes support fromRecord() factory methods for easy creation from database records:

Configure Your Model:

Each shape type supports the fromRecord() method with common parameters:

Circle from Record
Polygon from Record
Polyline from Record
Rectangle from Record

Shape Styling

Editable Layers

Make markers and shapes editable directly on the map by enabling the draw control:

You can also make all layers in a group editable:

User Interactions

Popups and Tooltips

Tooltips (appear on hover)

Popups (appear on click)

How popup fields work: Keys are automatically converted to title case, underscores replaced with spaces, and translated using Laravel's __() helper. Both keys and values support translation keys.

Combined Usage

Click Actions

Marker Click Handler

Shape Click Handler

From Model Records

Map Click Handler

Handle clicks on the map itself:

Field/Entry/Column Click Handlers

Handle map clicks in form fields, infolists, or table columns:

Handle layer (marker/shape) clicks:

Advanced Features

Model Integration & CRUD Operations

Enable creating markers directly from map clicks:

When users click the map, a form modal opens to create a new marker. The widget automatically converts latitude/longitude into the configured coordinates column.

Built-in Marker Actions:

Define custom actions to execute when clicking markers with records using the $markerClickAction property:

Available marker click actions:

Using a Resource Form:

Hooks:

Keep Maps in Sync with Tables:

This automatically refreshes the map after create/edit/delete actions.

GeoJSON Density Maps

Display choropleth maps with custom density data:

Colors are automatically applied based on data distribution.

Multi-Language Support

The package includes built-in support for: English (en), Portuguese (pt_BR, pt_PT), Spanish (es), French (fr), German (de), Italian (it).

All draw control labels, tooltips, and messages are automatically translated based on your application's locale.

To customize translations:

Then edit files in lang/vendor/filament-leaflet.

Best Practices

Performance Optimization

  1. Use Marker Clusters for large datasets:

  2. Limit data with query modifications:

  3. Use appropriate zoom levels:

Debugging

Enable logging for map interactions:

Configuration Reference

Customization

Custom Styles

Add custom CSS to your map:

Custom Scripts

Execute JavaScript after map initialization:

Method Reference

GeoSearchInput

Method Description
provider($provider) Set geocoding provider (Nominatim, GoogleMaps, Mapbox, BingMaps)
limit($count) Set maximum results (1–50, default 25)
withAddressDetails($enabled) Include structured address in results (default true)
language($code) Set preferred language (e.g., 'pt-BR', 'en')
countryCodes($codes) Restrict to country codes (e.g., 'br', ['br', 'ar'])
viewbox($minLon, $minLat, $maxLon, $maxLat) Set bounding box to bias/restrict results
bounded($enabled) Strictly restrict results to viewbox (default false)
cacheResults($ttl) Cache results for given seconds (default 3600)
minSearchLength($chars) Minimum characters before searching (default 2)
useShortLabels($enabled) Use short labels instead of full address (default false)
textMode($enabled) Return text only instead of coordinates (default false)

MapWidget

Method Description
getHeading() Returns the widget heading
getAutoCenter() Returns the auto-center setting
getMarkers() Returns array of markers to display
getShapes() Returns array of shapes to display
getLayers() Returns combined markers and shapes
onMapClick($lat, $lng) Handles map click events
onLayerClick($layerId) Handles layer click events
refreshMap() Manually refresh the map
afterMarkerCreated($record) Hook after marker creation
mutateFormDataBeforeCreate($data) Transform form data before save
$markerClickAction Define action for marker clicks (view/edit/delete)
$markerModel Eloquent model class for markers (enables CRUD)
$markerResource Optional Filament Resource for marker actions
$coordinatesColumnName Optional Column name for coordinates in CRUD (null uses config default)

MapPicker

Method Description
make($name) Create a new MapPicker field
autoCenter(bool) Auto-center map to user's current location
center($lat, $lng) Set map center coordinates
zoom($level) Set initial zoom level
height($pixels) Set map height
mapDraggable($bool) Enable/disable map dragging
mapZoomable($bool) Enable/disable map zooming
static() Disable all map interactions (dragging & zooming)
recenterTimeout($milliseconds) Auto-recenter map after X ms of inactivity
tileLayersUrl($layers) Set tile layer(s)
markers($array) Set initial markers
shapes($array) Set initial shapes
geoJsonUrl($url) Set GeoJSON URL
geoJsonData($data) Set GeoJSON density data
geoJsonTooltip($tooltip) Set GeoJSON tooltip template
pickMarker($marker) Customize the temporary marker shown on click
onMapClick($callback) Handle map click events with closure callback
onLayerClick($callback) Handle layer click events with closure callback
handleMapClick($lat, $lng) Exposed Livewire method for map clicks
handleLayerClick($layerId) Exposed Livewire method for layer clicks

MapEntry

Method Description
make($name) Create a new MapEntry entry
autoCenter(bool) Auto-center map to user's current location
center($lat, $lng) Set map center coordinates
zoom($level) Set initial zoom level
height($pixels) Set map height
mapDraggable($bool) Enable/disable map dragging
mapZoomable($bool) Enable/disable map zooming
static() Disable all map interactions (dragging & zooming)
recenterTimeout($milliseconds) Auto-recenter map after X ms of inactivity
tileLayersUrl($layers) Set tile layer(s)
markers($array) Set initial markers
shapes($array) Set initial shapes
geoJsonUrl($url) Set GeoJSON URL
geoJsonData($data) Set GeoJSON density data
geoJsonTooltip($tooltip) Set GeoJSON tooltip template
pickMarker($marker) Customize the temporary marker shown on click
onMapClick($callback) Handle map click events with closure callback
onLayerClick($callback) Handle layer click events with closure callback

MapColumn

Method Description
make($name) Create a new MapColumn column
autoCenter(bool) Auto-center map to user's current location
center($lat, $lng) Set map center coordinates
zoom($level) Set initial zoom level
height($pixels) Set map height
circular($value) Display map as circular container
mapDraggable($bool) Enable/disable map dragging
mapZoomable($bool) Enable/disable map zooming
static() Disable all map interactions (dragging & zooming)
recenterTimeout($milliseconds) Auto-recenter map after X ms of inactivity
tileLayersUrl($layers) Set tile layer(s)
markers($array) Set initial markers
shapes($array) Set initial shapes
geoJsonUrl($url) Set GeoJSON URL
geoJsonData($data) Set GeoJSON density data
geoJsonTooltip($tooltip) Set GeoJSON tooltip template
pickMarker($marker) Customize the temporary marker shown on click
onMapClick($callback) Handle map click events with closure callback
onLayerClick($callback) Handle layer click events with closure callback

Marker

Method Description
make($lat, $lng) Create a new marker
fromRecord() Create marker from Eloquent model
id($id) Set marker ID
title($title) Set title (tooltip & popup)
color($color) Set marker color
icon($icon, $size) Set custom icon URL or Heroicon
iconUrl($url) Set custom icon URL
iconSize($size) Set icon size as [width, height]
heroicon($icon) Set Heroicon (string or Heroicon enum)
draggable($bool) Make marker draggable
editable($bool) Make marker editable on the map
group($group) Assign to group (string or BaseLayerGroup)
popup($content, $fields, $options) Configure popup
tooltip($content, $permanent, $direction, $options) Configure tooltip
action($callback) Set click handler
distanceTo($marker) Calculate distance to another marker
validate() Validate coordinates

Shape (All Shapes)

Method Description
color($color) Set border color
fillColor($color) Set fill color
weight($pixels) Set border width
opacity($value) Set border opacity (0-1)
fillOpacity($value) Set fill opacity (0-1)
dashArray($pattern) Set dash pattern
editable($bool) Make shape editable on the map
popup($content, $fields, $options) Configure popup
tooltip($content, $permanent, $direction, $options) Configure tooltip
action($callback) Set click handler
group($group) Assign to group (string or BaseLayerGroup)
getCoordinates() Get center coordinates of the shape

Circle

Method Description
make($lat, $lng) Create circle
radius($meters) Set radius in meters
radiusInMeters($meters) Set radius in meters
radiusInKilometers($km) Set radius in kilometers
radiusInMiles($miles) Set radius in miles
radiusInFeet($feet) Set radius in feet

CircleMarker

Method Description
make($lat, $lng) Create circle marker
radius($pixels) Set radius in pixels

Polygon & Polyline

Method Description
make($coordinates) Create with coordinates
addPoint($lat, $lng) Add vertex/point

Polyline

Method Description
smoothFactor($factor) Set line smoothing

Rectangle

Method Description
make($corner1, $corner2) Create with corners
makeFromCoordinates($lat1, $lng1, $lat2, $lng2) Create with coordinates

Layer Group (Base)

Method Description
make($layers) Create layer group with layers
id($id) Set group ID
name($name) Set group name
option($key, $value) Set a group option
getLayers() Get all layers in the group

LayerGroup

Method Description
make($layers) Create simple layer group
name($name) Set user-visible group name
id($id) Set group ID for controls
editable($bool) Make all layers in group editable

FeatureGroup

Method Description
make($markers) Create feature group from markers
name($name) Set zone/area name
blue(), red(), etc. Set border color
fillBlue(), fillRed(), etc. Set fill color
fillOpacity($value) Set fill transparency (0-1)
weight($pixels) Set border width
editable($bool) Make all layers in group editable

MarkerCluster

Method Description
make($markers) Create cluster with markers
fromModel() Create cluster from Eloquent model
marker($marker) Add single marker
markers($array) Add multiple markers
name($name) Set cluster group name
editable($bool) Make all markers in cluster editable
maxClusterRadius($pixels) Set cluster radius (pixels)
showCoverageOnHover($bool) Show cluster coverage on hover
zoomToBoundsOnClick($bool) Zoom to bounds when clicked
spiderfyOnMaxZoom($bool) Spread markers at max zoom
disableClusteringAtZoom($level) Disable clustering at zoom level
animate($bool) Animate cluster changes
modifyQueryUsing($callback) Modify database query
mapRecordUsing($callback) Customize each marker

Color Reference

Markers and shapes accept colors from multiple sources:

Tile Layer Reference

Available tile layer providers:

Value Objects Reference

Coordinate

The Coordinate value object represents a geographical point with latitude and longitude coordinates. It's used throughout the package for storing and manipulating map coordinates.

Storage Modes:

The Coordinate cast supports two storage modes:

  1. JSON Column - Store coordinates as JSON in a single column
  2. Virtual Attribute - Manage separate latitude and longitude columns automatically

Usage in Models - JSON Column:

Usage in Models - Virtual Attribute (Separate Columns):

If you have separate latitude and longitude columns, use the cast with column parameters:

Practical Example - Virtual Attribute:

Basic Usage:

Methods:

Method Description
__construct($lat, $lng) Create a new Coordinate instance
toArray() Convert to associative array with 'lat' and 'lng' keys
toFlatArray() Convert to flat array [$lat, $lng]
fromArray($array) Create from array with 'lat'/'lng' or numeric keys
fromObject($object) Create from object with lat/lng properties
from($coordinates) Universal factory method for arrays, objects, or Coordinate instances
distanceTo($other) Calculate distance to another Coordinate (in kilometers)
castUsing() Internal method for configuring Eloquent casting

GeoSearchResult

The GeoSearchResult value object represents a geocoding search result with complete location information from geocoding providers.

Properties:

Address

The Address value object contains structured address information from geocoding results.

Properties:

Property Type Description
suburb string|null Suburb or neighborhood name
cityDistrict string|null City district
city string|null City name (town, village)
county string|null County name
state string|null State or province
province string|null Province name
region string|null Region name
postcode string|null Postal code
country string|null Country name
countryCode string|null ISO 3166-1 country code

Concern Methods Reference

HasGeoJsonFile

Method Description
getGeoJsonFileAttributeName() Returns the model attribute storing GeoJSON (default: 'geojson')
getGeoJsonFileDisk() Returns the storage disk for the file (default: null = local)
getExpirationTime() Returns DateTime for temporary URL expiration (default: null = permanent)
getGeoJsonUrl() Returns the accessible URL for the GeoJSON file

Map Configuration Properties

These properties control core map behavior:

Property Type Default Description
$mapCenter array null Initial map center [latitude, longitude] (null uses config default)
$autoCenter bool false Auto-center to user's current location on load
$defaultZoom int 4 Initial zoom level
$mapHeight int 598 Map height in pixels
$mapDraggable bool true Allow users to pan by dragging
$mapZoomable bool true Allow users to zoom (scroll wheel, pinch)
$recenterMapTimeout ?int null Auto-recenter after X milliseconds of panning
$maxZoom int 19 Maximum zoom level allowed
$minZoom int 2 Minimum zoom level allowed
$hasDrawMarkerControl bool false Show draw marker control
$hasDrawCircleMarkerControl bool false Show draw circle marker toolbar
$hasDrawCircleControl bool false Show draw circle toolbar
$hasDrawPolylineControl bool false Show draw polyline toolbar
$hasDrawRectangleControl bool false Show draw rectangle toolbar
$hasDrawPolygonControl bool false Show draw polygon toolbar
$hasDrawTextControl bool false Show draw text toolbar
$hasEditLayersControl bool false Show edit layers toolbar
$hasDragLayersControl bool false Show drag layers toolbar
$hasRemoveLayersControl bool false Show remove layers toolbar
$hasRotateLayersControl bool false Show rotate layers toolbar
$hasCutPolygonControl bool false Show cut polygon toolbar
$hasFullscreenControl bool false Show fullscreen button
$hasSearchControl bool false Show address search
$hasScaleControl bool false Show distance scale
$hasZoomControl bool true Show zoom +/- buttons
$hasAttributionControl bool false Show attribution text
$tileLayersUrl mixed OpenStreetMap Base map tile layers

License

This package is open-sourced software licensed under the MIT license. Check the LICENSE file for more information.

Credits

Support

For issues, questions, or contributions, please visit the GitHub repository. Don't forget, Jesus loves you ❀️.


All versions of filament-leaflet with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
filament/filament Version ^4.0|^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package eduardoribeirodev/filament-leaflet contains the following files

Loading the files please wait ...