You are here

public function Layer::optionsToObjects in Openlayers 7.3

Return a flat array containing Openlayers Objects from the options array.

Return value

ObjectInterface[] Return a list of objects.

Overrides Base::optionsToObjects

1 method overrides Layer::optionsToObjects()
Group::optionsToObjects in src/Plugin/Layer/Group/Group.php
Return a flat array containing Openlayers Objects from the options array.

File

src/Types/Layer.php, line 64
Class Layer.

Class

Layer
Class Layer.

Namespace

Drupal\openlayers\Types

Code

public function optionsToObjects() {
  $import = parent::optionsToObjects();
  foreach (array(
    'style',
    'source',
  ) as $option) {
    if ($option_value = $this
      ->getOption($option, FALSE)) {
      if ($object = $this
        ->getCollection()
        ->getObjectById($option, $option_value)) {
        $import = array_merge($import, $object
          ->getCollection()
          ->getFlatList());
      }
      else {
        $import = array_merge($import, Openlayers::load($option, $option_value)
          ->getCollection()
          ->getFlatList());
      }
    }
  }
  return $import;
}