bigfork/silverstripe-mapboxfield

Mapbox CMS field for SilverStripe 4

Installs: 2 508

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 5

Forks: 9

Open Issues: 5

Language:JavaScript

Type:silverstripe-vendormodule

0.0.3 2019-04-10 12:51 UTC

This package is auto-updated.

Last update: 2024-03-27 09:32:25 UTC


README

Adds a Mapbox map to the CMS with a draggable marker to allow content authors to add a location to a DataObject or Page.

Installation

composer require bigfork/silverstripe-mapboxfield:*

Configuration

---
Name: 'app-mapbox'
After: 'silverstripe-mapboxfield'
---
Bigfork\SilverStripeMapboxField\MapboxField:
  access_token: '<your mapbox key>'

Usage

class MyDataObject extends DataObject
{
    private static $db = [
        'Latitude' => 'Decimal(10, 8)',
        'Longitude' => 'Decimal(11, 8)'
    ];

    public function getCMSFields()
    {
        // ...

        $fields->addFieldToTab(
            'Root.Map',
            MapboxField::create('LocationMap', 'Choose a location', 'Latitude', 'Longitude')
        );

        // ...
    }
}