Download the PHP package doode/filament-map-picker without Composer
On this page you can find all versions of the php package doode/filament-map-picker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download doode/filament-map-picker
More information about doode/filament-map-picker
Files in doode/filament-map-picker
Package filament-map-picker
Short Description Easily pick and retrieve geo-coordinates using a map-based interface with geoman.io extension map draw tools.
License MIT
Homepage https://github.com/vitormicillo/filament-map-picker
Informations about the package filament-map-picker
Filament V3 Map Picker + Geoman Drawing Plugin
Introduction
Map Picker is a custom field of Filament designed to simplify the process of selecting a location on a map and obtaining its geo-coordinates with the ease of having the Geoman plugin embedded in the map.
- Features include:
- A Field for Filament-v3 with Leaflet Map Integration
- Receive Real-time Coordinates Upon Marker Movement Completion
- Tailor Controls and Marker Appearance to Your Preferences
- Latest versions of PHP and Filament
- Best practices applied:
README.md
(badges included)LICENSE
composer.json
.gitignore
pint.json
GeoMan Integration
This package now includes integration with GeoMan, a powerful tool for creating and editing geometries on maps. GeoMan allows users to draw various shapes, edit existing geometries, and perform advanced map editing tasks.
GeoMan Features:
- Draw markers, polygons, polylines, and circles
- Edit existing geometries
- Cut polygons
- Rotate shapes
- Drag mode for easy shape manipulation
- Delete layers
Supported Maps
Map Picker currently supports the following map:
- Open Street Map (OSM)
- Google Maps
Installation
You can easily install the package via Composer:
Basic
Usage
Resource file:
clickable
Option
This will allow you to set the point on the map with a click. Default behaviour has the marker centered as the map is dragged underneath. You could, with this, keep the map still and lock the zoom and choose to click to place the marker.
rangeSelectField
Option
The rangeSelectField Option allows you to specify another field on your form which specifies a range from the point identified by the marker. That field must be in meters. So for example you could do this:
In this case, as you change the value on the Select a circle of that radius centered on the marker will change to match your drop down.
liveLocation
Option
The liveLocation
method accepts three parameters:
bool $send
: Determines if the user's live location should be sent.bool $realtime
: Controls whether the live location should be sent to the server periodically.int $milliseconds
: Sets the interval (in milliseconds) at which the user's location is updated and sent to the server.
Example:
boundaries Option
The idea here is that you can set a boundary box by defining two points, the southwest most point and the north east most point, and your map will pan back into the panned area if you drag away, such that the points can only be selected if you stay in the map.
You will want to set the minZoom() along with this if you set showZoomControl(true). To choose a good value for minZoom() you will need to consider both the size of the map on the screen and the size of the bounding boxm, and you may find trial and error is the best method.
To turn it off again - possibly a strange use case - boundaries(false)
is what you want.
setBoundsToBritishIsles Option
This is a convenience function that uses the boundaries option above, setting the boundary box to (49.5,-11) and (61,2)
Options Table
Here's a table describing all available options and their default values:
Option | Description | Default Value |
---|---|---|
draggable | Allow map dragging | true |
showMarker | Display marker on the map | true |
tilesUrl | URL for map tiles | 'http://tile.openstreetmap.org/{z}/{x}/{y}.png' |
attribution | Map attribution text | null |
zoomOffset | Zoom offset | -1 |
tileSize | Tile size | 512 |
detectRetina | Detect and use retina tiles | true |
minZoom | Minimum zoom level | 0 |
maxZoom | Maximum zoom level | 28 |
zoom | Default zoom level | 15 |
markerColor | Color of the marker | '#3b82f6' |
liveLocation | Enable live location updates | [false, false, 5000] |
showMyLocationButton | Show "My Location" button | false |
default | Default location | ['lat' => 0, 'lng' => 0] |
geoManToolbox.show | Enable GeoMan | false |
geoMan.editable | Allow editing with GeoMan | true |
geoMan.position | Position of GeoMan controls | 'topleft' |
geoMan.drawCircleMarker | Allow drawing circle markers | true |
geoMan.rotateMode | Enable rotate mode | true |
geoMan.drawText | Allow drawing text blocks | false |
geoMan.drawMarker | Allow drawing markers | true |
geoMan.drawPolygon | Allow drawing polygons | true |
geoMan.drawPolyline | Allow drawing polylines | true |
geoMan.drawCircle | Allow drawing circles | true |
geoMan.dragMode | Enable drag mode | true |
geoMan.cutPolygon | Allow cutting polygons | true |
geoMan.editPolygon | Allow editing polygons | true |
geoMan.deleteLayer | Allow deleting layers | true |
geoMan.color | Stroke color for drawings | '#3388ff' |
geoMan.filledColor | Fill color for drawings | '#cad9ec' |
New feature to capture image from the map
This is an example of the code in how to trigger the function in the map in order to capture the snapshot. Note: Latitude and longitude are not mandatory, you can move the map and trigger the action to capture the image.
“If you have Geoman shapes drawn on your map, they will be included in the generated image.”
In your web.php file is necessary to add the route, i.e you can use a custom Controller The map feature will post the blob image to this url /upload-map-image
If you wish to update the map location and marker either through an action or after altering other input values, you can trigger a refresh of the map using the following approach:
Usage As Infolist Field
The MapEntry Infolist field displays a map.
Usage Guide for Handling Map Locations
This section explains how to handle and display map locations within your application using this package.
Step 1: Define Your Database Schema
Ensure your database table includes latitude and longitude columns. This is essential for storing the coordinates of your locations. You can define your table schema as follows:
Step 2: Retrieve and Set Coordinates
When loading a record, ensure you correctly retrieve and set the latitude and longitude values. Use the following method within your form component:
Step 3: Add Form Fields for Latitude and Longitude
Add hidden form fields for latitude and longitude to your form. This ensures the values are present but not visible to the user:
If you prefer to display these values in a read-only format, replace hidden()
with readOnly()
.
Alternative Approach: Using a Single Location Attribute
If you prefer to handle the location as a single field, you can define a custom attribute in your model. This method avoids the need for separate latitude and longitude columns:
This approach encapsulates both latitude and longitude within a single location attribute, streamlining your code.
Updates for version 1.4.0 and above
User can customize marker icons now, It is possible to use SVG or base64 encoded value
User can set the marker size using ->iconSize()
Example in how to use custom SVG Icon when "edit" a record from database
Another way to update in real time if you have a list of icons in a dropdown list You can display the icon in the list as well and use this icon to set as a marker in the map, like the example below.
You can do it in your way, just call $livewire
and pass the parameter 'updateMarkerIcon'
License
MIT License © Doode
Security
We take security seriously.
If you discover any bugs or security issues, please help us maintain a secure project by reporting them through our GitHub issue tracker
.
You can also contact us directly at [email protected].
Contribution
We welcome contributions! contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
All versions of filament-map-picker with dependencies
filament/filament Version ^3.2
spatie/laravel-package-tools Version ^1.15.0
illuminate/contracts Version ^10.0 || ^11.0