PHP code example of goldfinch / silverstripe-googlemapfield
1. Go to this page and download the library: Download goldfinch/silverstripe-googlemapfield library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
goldfinch / silverstripe-googlemapfield example snippets
use SilverStripe\ORM\DataObject;
use BetterBrief\GoogleMapField;
class Store extends DataObject
{
private static $db = [
'Title' => 'Varchar(255)',
'Latitude' => 'Varchar',
'Longitude' => 'Varchar',
'Zoom' => 'Int',
];
public function getCMSFields() {
$fields = parent::getCMSFiels();
// add the map field
$fields->addFieldToTab('Root.Main', new GoogleMapField(
$this,
'Location'
));
// remove the lat / lng fields from the CMS
$fields->removeFieldsFromTab('Root.Main', ['Latitude', 'Longitude']);
return $fields;
}
}