Extends FormField. Form field for editing geo types.
Location to center empty MapFields and GridFieldMaps to
MapField::$default_location = [
'lon' => 174.78,
'lat' => -41.29,
];
- lon (float) is the default location's longitude as a float
- lat (float) is it's latitude as a float
Enable multi geometries like MultiPoint or MultiPolygon
- $enable (bool) whether to enable or disable the control in the widget
Returns the MapField instance for chaining
Hide form field showing the actual EWKT value that will be stored in the database.
- $hide (bool) whether to hide or shoe the readonly field
Returns the MapField instance for chaining
Hide controls for selected shape types
- $shapeType (string) Leaflet shape type, Note: those are different from the GIS shapes
- $enabled (bool) whether to enable or disable the control in the widget
Returns the MapField instance for chaining
After adding a new geo type to your DataObjects db fields, the form scaffolder automatically gives you a MapField to your ModelAdmin form. If you need to add one to your admin form manually e.g. because the form doesn't use the default scaffolder like CMS you can add it to your DataObject like this:
app/src/Model/CityPage.php
<?php
use Smindel\GIS\Forms\MapField;
class CityPage extends Page
{
private static $db = [
'Location' => 'Geometry',
]
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab(
'Root.Main',
MapField::create('Location')
->setControl('polygon', false)
->setControl('polyline', false),
'Content'
);
return $fields;
}
}