Download the PHP package marshmallow/nova-map-box-field without Composer
On this page you can find all versions of the php package marshmallow/nova-map-box-field. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download marshmallow/nova-map-box-field
More information about marshmallow/nova-map-box-field
Files in marshmallow/nova-map-box-field
Package nova-map-box-field
Short Description A field for Laravel Nova 4 to create mapbox polygons and store them into your database. Awesome stuff really!
License MIT
Informations about the package nova-map-box-field

Nova MapBox Field
A field for Laravel Nova to create MapBox polygons and store them into your database. Awesome stuff really!
Installation
Install the package via Composer:
The package registers itself through Laravel's package auto-discovery, so the field's assets are served to Nova automatically.
Publish the config file
Add your MapBox token
The field needs a public MapBox access token. Set it in your .env:
Configuration
After publishing, the defaults live in config/nova-map-box-field.php. Every value is used to initialise a new MapBox field and can be overridden per field with the methods documented under Usage.
| Key | Default | Description |
|---|---|---|
mapbox_key |
env('MAPBOX_PUBLIC_KEY') |
Your public MapBox access token. |
default.height |
300 |
Map height in pixels. |
default.zoom |
8 |
Initial zoom level. |
default.latitude |
52.111221 |
Latitude the map is centered on. |
default.longitude |
4.647251 |
Longitude the map is centered on. |
default.style |
mapbox://styles/mapbox/light-v10 |
MapBox style URL. |
default.container |
map |
DOM container identifier for the map. |
default.navigation_controls |
false |
Show MapBox navigation controls. |
default.draw_controls |
false |
Show the polygon drawing controls. |
default.polygon_preview.color |
#ff133b |
Fill color used when previewing polygons. |
default.polygon_preview.opacity |
0.5 |
Fill opacity used when previewing polygons. |
Usage
Add the field to a Nova resource. By default the field is hidden from the index view.
Customising the map
All map options can be overridden per field. The values default to your config file.
Centering the map dynamically
Use setCenter() to derive the center from the resource. Return an [latitude, longitude] array, or a falsy value to keep the current center.
Adding markers
addMarker() pushes a marker onto the map. Return an [latitude, longitude] array, or a falsy value to add nothing. Call it multiple times to add multiple markers.
A default polygon
Draw a default polygon around a coordinate within a given range in kilometres.
Prefilling polygons
Use prefillWith() to render existing polygons on the map. The callback must return an array of Marshmallow\MapBox\Polygon objects; anything else throws an exception.
Credits
License
The MIT License. Please see the License File for more information.