Google Map and Google Place (Autocomplete) fields for Silverstripe
composer require goldfinch/google-fields
.env
APP_GOOGLE_MAPS_KEY=""
Library required Maps JavaScript API
use Goldfinch\GoogleFields\Forms\MapField;
private static $db = [
'Map' => 'Map',
];
// ..
MapField::create('Map')
//
MapField::create('Map', 'Map')
->setSettings([
'lng' => 168.7439017,
'lat' => -45.0136784,
'zoom' => 10,
])
->mapHideSearch()
->mapHideExtra()
->mapReadonly()
<!-- template.ss -->
$Map
$Map.Link
$Map.Longitude
$Map.Latitude
$Map.Zoom
Library required Places API
use Goldfinch\GoogleFields\Forms\PlaceField;
private static $db = [
'Place' => 'Place',
];
// ...
PlaceField::create('Place')
//
PlaceField::create('Place', 'Place')
->setSettings([
'country' => 'ru',
])
->placeHidePreview()
<!-- template.ss -->
$Place.Address
$Place.Data
$Place.Link
$Place.Subpremise
$Place.StreetNumber
$Place.StreetName
$Place.Suburb
$Place.Subarea
$Place.Region
$Place.District
$Place.Country
$Place.Postcode
$Place.PlaceName
$Place.Latitude
$Place.Longitude
The MIT License (MIT)