2018-11-29 18:38:20 +01:00
|
|
|
# SilverStripe Mapbox Field
|
|
|
|
|
|
|
|
Adds a Mapbox map to the CMS with a draggable marker to allow content authors to add a location to a DataObject or Page.
|
|
|
|
|
2018-11-29 18:40:02 +01:00
|
|
|
<img src="docs/img/cms.png" alt="" />
|
2018-11-29 18:38:20 +01:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
`composer require bigfork/silverstripe-mapboxfield:*`
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
```yml
|
|
|
|
---
|
|
|
|
Name: 'app-mapbox'
|
|
|
|
After: 'silverstripe-mapboxfield'
|
|
|
|
---
|
|
|
|
Bigfork\SilverStripeMapboxField\MapboxField:
|
|
|
|
access_token: '<your mapbox key>'
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```php
|
|
|
|
class MyDataObject extends DataObject
|
|
|
|
{
|
|
|
|
private static $db = [
|
|
|
|
'Latitude' => 'Decimal(10, 8)',
|
2018-12-07 03:11:53 +01:00
|
|
|
'Longitude' => 'Decimal(11, 8)'
|
2018-11-29 18:38:20 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
public function getCMSFields()
|
|
|
|
{
|
|
|
|
// ...
|
|
|
|
|
|
|
|
$fields->addFieldToTab(
|
|
|
|
'Root.Map',
|
|
|
|
MapboxField::create('LocationMap', 'Choose a location', 'Latitude', 'Longitude')
|
|
|
|
);
|
|
|
|
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|