DEPRECATION WARNING

This documentation is not using the current rendering mechanism and will be deleted by December 31st, 2020. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

Edit Marker

Maps2 comes with an editPoi widget, which you can insert in your template. The widget will automatically insert some hidden fields which will be filled with the current location of the marker. The website visitor can move that marker around via Drag ‘n Drop or while clicking somewhere on the map.

<maps2:widget.editPoi poiCollection="{company.txMaps2Uid}" override="{settings: {mapWidth: '100%', mapHeight: '300'}}" />

There are 3 hidden fields which will be rendered.

<input name="tx_maps2[__identity]" value="2" type="hidden">
<input id="latitude-73" name="tx_maps2[latitude]" value="51.091152" type="hidden">
<input id="longitude-73" name="tx_maps2[longitude]" value="7.545384" type="hidden">

Now it’s time to process the fields in your controller.

/**
 * initialize create action
 * allow modification of submodel
 *
 * @return void
 */
public function initializeCreateAction()
{
  $maps2Request = GeneralUtility::_POST('tx_maps2');
  if (isset($maps2Request)) {
    $company = $this->request->getArgument('company');
    $company['txMaps2Uid'] = $maps2Request;
    $this->request->setArgument('company', $company);
  }
  $this->arguments->getArgument('company')->getPropertyMappingConfiguration()->allowModificationForSubProperty('txMaps2Uid');
  $this->arguments->getArgument('company')->getPropertyMappingConfiguration()
    ->allowProperties('txMaps2Uid')
    ->forProperty('txMaps2Uid')->allowProperties('latitude', 'longitude', '__identity');
}