PHPackages                             marshmallow/nova-map-box-field - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. marshmallow/nova-map-box-field

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

marshmallow/nova-map-box-field
==============================

A field for Laravel Nova 4 to create mapbox polygons and store them into your database. Awesome stuff really!

v1.3.2(2y ago)12.5k↓66.7%MITVuePHP ^8.1

Since Aug 26Pushed 3w ago1 watchersCompare

[ Source](https://github.com/marshmallow-packages/nova-map-box-field)[ Packagist](https://packagist.org/packages/marshmallow/nova-map-box-field)[ RSS](/packages/marshmallow-nova-map-box-field/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (9)DependenciesVersions (11)Used By (0)

[![alt text](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67 "marshmallow.")](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67)

Nova MapBox Field
=================

[](#nova-mapbox-field)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5708401eeb47c2e954fa7860a686a59e3c2d93a7a4b24409c16fbdf8afb34e3f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617273686d616c6c6f772f6e6f76612d6d61702d626f782d6669656c642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marshmallow/nova-map-box-field)[![Total Downloads](https://camo.githubusercontent.com/f5a0432976def949d5efef7c287afb9f75cd937a37388a33674ce1c78c1d4a11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617273686d616c6c6f772f6e6f76612d6d61702d626f782d6669656c642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marshmallow/nova-map-box-field)

A field for Laravel Nova to create MapBox polygons and store them into your database. Awesome stuff really!

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require marshmallow/nova-map-box-field
```

The package registers itself through Laravel's package auto-discovery, so the field's assets are served to Nova automatically.

### Publish the config file

[](#publish-the-config-file)

```
php artisan vendor:publish --provider="Marshmallow\MapBox\FieldServiceProvider"
```

### Add your MapBox token

[](#add-your-mapbox-token)

The field needs a public MapBox access token. Set it in your `.env`:

```
MAPBOX_PUBLIC_KEY=your-mapbox-public-token
```

Configuration
-------------

[](#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](#usage).

KeyDefaultDescription`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
-----

[](#usage)

Add the field to a Nova resource. By default the field is hidden from the index view.

```
use Marshmallow\MapBox\MapBox;

public function fields(NovaRequest $request)
{
    return [
        MapBox::make('Area', 'area'),
    ];
}
```

### Customising the map

[](#customising-the-map)

All map options can be overridden per field. The values default to your config file.

```
use Marshmallow\MapBox\MapBox;

MapBox::make('Area', 'area')
    ->height(400)
    ->defaultZoom(10)
    ->latitude(52.111221)
    ->longitude(4.647251)
    ->style('mapbox://styles/mapbox/streets-v11')
    ->navigationControls(true)
    ->drawControls(true)
    ->polygonPreviewColor('#ff133b')
    ->polygonPreviewOpacity(0.5);
```

### Centering the map dynamically

[](#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.

```
MapBox::make('Area', 'area')
    ->setCenter(function ($field) {
        return [52.111221, 4.647251];
    });
```

### Adding markers

[](#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.

```
MapBox::make('Area', 'area')
    ->addMarker(fn ($field) => [52.111221, 4.647251])
    ->addMarker(fn ($field) => [51.924420, 4.477733]);
```

### A default polygon

[](#a-default-polygon)

Draw a default polygon around a coordinate within a given range in kilometres.

```
MapBox::make('Area', 'area')
    ->defaultPolygon(latitude: 52.111221, longitude: 4.647251, range_in_km: 5);
```

### Prefilling polygons

[](#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.

```
use Marshmallow\MapBox\MapBox;
use Marshmallow\MapBox\Polygon;

MapBox::make('Area', 'area')
    ->prefillWith(function ($field) {
        return [
            new Polygon(
                polygon: [[52.111221, 4.647251], [52.120000, 4.650000], [52.115000, 4.660000]],
                color: '#ff133b',
                opacity: 0.5,
            ),
        ];
    });
```

Credits
-------

[](#credits)

- [Marshmallow](https://github.com/marshmallow-packages)
- [All Contributors](https://github.com/marshmallow-packages/nova-map-box-field/contributors)

License
-------

[](#license)

The MIT License. Please see the [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance62

Regular maintenance activity

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~69 days

Recently: every ~42 days

Total

9

Last Release

850d ago

Major Versions

v0.1.0 → v1.0.02023-09-19

PHP version history (2 changes)v0.0.1PHP ^8.0

v1.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/be33d2624e24c516e73892b0929447cc762f3622c024ab8d0d2a59042e5d2c7f?d=identicon)[marshmallow](/maintainers/marshmallow)

---

Top Contributors

[![stefvanesch](https://avatars.githubusercontent.com/u/46725619?v=4)](https://github.com/stefvanesch "stefvanesch (15 commits)")

---

Tags

laravelnovamap box

### Embed Badge

![Health badge](/badges/marshmallow-nova-map-box-field/health.svg)

```
[![Health](https://phpackages.com/badges/marshmallow-nova-map-box-field/health.svg)](https://phpackages.com/packages/marshmallow-nova-map-box-field)
```

###  Alternatives

[optimistdigital/nova-multiselect-field

A multiple select field for Laravel Nova.

3453.7M8](/packages/optimistdigital-nova-multiselect-field)[inspheric/nova-defaultable

Default values for Nova fields when creating resources and running resource actions.

52178.7k1](/packages/inspheric-nova-defaultable)[murdercode/nova4-tinymce-editor

Boost your Laravel Nova with the TinyMCE editor.

17186.3k1](/packages/murdercode-nova4-tinymce-editor)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11273.0k](/packages/datomatic-nova-detached-actions)[wemersonrv/input-mask

A Laravel Nova custom field text with masks on input

1198.4k](/packages/wemersonrv-input-mask)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
