public function OL3LayerSwitcher::preBuild in Openlayers 7.3
Invoked before an objects render array is built.
Mostly invoked by the map object.
Parameters
array $build: The array with the build information.
\Drupal\openlayers\Types\ObjectInterface $context: The context of the build. Mostly the map object.
Overrides Base::preBuild
File
- modules/
openlayers_library/ src/ Plugin/ Control/ OL3LayerSwitcher/ OL3LayerSwitcher.php, line 36 - Control: Attribution.
Class
- OL3LayerSwitcher
- Class OL3LayerSwitcher.
Namespace
Drupal\openlayers_library\Plugin\Control\OL3LayerSwitcherCode
public function preBuild(array &$build, ObjectInterface $context = NULL) {
array_map(function ($layer) {
/** @var LayerInterface $layer */
if (!in_array($layer
->getFactoryService(), array(
'openlayers.Layer:Vector',
'openlayers.Layer:Heatmap',
))) {
$layer
->setOption('type', 'base');
}
}, $context
->getObjects('layer'));
}