/**
  * {@inheritdoc}
  */
 protected function build(Definition $definition, \Model $model, DefinitionMapper $mapper, Filter $filter = null, Definition $parent = null)
 {
     parent::build($definition, $model, $mapper, $filter);
     if ($definition instanceof SpinJsLoadingControl && $model->spin) {
         $config = json_decode($model->spin, true);
         if (is_array($config)) {
             $definition->setSpin($config);
         }
     }
     if ($definition instanceof LoadingControl && !$definition->isSeparate() && $model->zoomControl) {
         // Only assign if zoom control is activated and part of the map.
         $control = ControlModel::findOneBy(array('active=1', 'type=?', 'pid=?', 'id=?'), array('zoom', $model->pid, $model->zoomControl));
         if ($control) {
             $control = $mapper->handle($control);
             if ($control instanceof Zoom) {
                 // By default the loading control overrides the position of the zoom control. Deactivate it by
                 // overriding the position.
                 $definition->setPosition($control->getPosition());
                 $definition->setZoomControl($control);
             }
         }
     }
 }
Example #2
0
 /**
  * Get the zoom controls for the reference value of the loading control.
  *
  * @return array
  */
 public function getZoomControls()
 {
     $collection = ControlModel::findBy('type', 'zoom', array('order' => 'title'));
     return OptionsBuilder::fromCollection($collection, 'id', 'title')->getOptions();
 }
 /**
  * Build map controls.
  *
  * @param Map              $map    The map being built.
  * @param MapModel         $model  The map model.
  * @param DefinitionMapper $mapper The definition mapper.
  * @param Filter           $filter Optional request filter.
  *
  * @return void
  */
 private function buildControls(Map $map, MapModel $model, DefinitionMapper $mapper, Filter $filter = null)
 {
     $collection = ControlModel::findActiveBy('pid', $model->id, array('order' => 'sorting'));
     if (!$collection) {
         return;
     }
     foreach ($collection as $control) {
         $control = $mapper->handle($control, $filter, null, $map);
         if ($control instanceof Control) {
             $control->addTo($map);
         }
     }
 }