PHP code example of innoweb / silverstripe-googlemapfield
1. Go to this page and download the library: Download innoweb/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/ */
innoweb / 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',
];
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;
}
}