You are here

function openlayers_map_form_controls_submit in Openlayers 7.3

Map controls config form submit handler.

File

modules/openlayers_ui/src/Plugin/export_ui/OpenlayersMaps.inc, line 510
CTools Export UI plugin definition for maps.

Code

function openlayers_map_form_controls_submit($form, &$form_state) {
  $map = \Drupal\openlayers\Openlayers::load('map', $form_state['item']);
  $controls_enabled = array_filter($form_state['values']['controls'], function ($item) {
    return (bool) $item['enabled'];
  });
  uasort($controls_enabled, function ($a, $b) {
    return $a['weight'] - $b['weight'];
  });
  $map
    ->setOption('controls', array_keys($controls_enabled));
  $form_state['item'] = $map
    ->getExport();
}