Repository URL to install this package:
|
Version:
1.0.4 ▾
|
<?php
namespace Drupal\premium_maps\Element;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Element\RenderElement;
/**
* Defines a render element for builder a map.
*
* @RenderElement("map")
*
* @internal
* Plugin classes are internal
*/
class Map extends RenderElement {
/**
* Returns the element properties for this element.
*
* @return array
* An array of element properties. See
* \Drupal\Core\Render\ElementInfoManagerInterface::getInfo() for
* documentation of the standard properties of all elements, and the
* return value format.
*/
public function getInfo() {
$class = get_class($this);
return [
'#theme' => 'map',
'#pre_render' => [
// [$class, 'onRenderFilters'],
// [$class, 'onRenderMap'],
],
'#attached' => [
'library' => [
'premium_maps/google_map',
],
],
];
}
/**
* Pre render function for the map.
*
* @param array $element
* The element.
*/
public function onRenderMap($element) {
if (!empty($element)) {
$markers = Element::children($element['markers']);
foreach ($markers as $marker) {
$element['#attached']['drupalSettings']['map'] = $marker;
}
}
}
public function onRenderFilters($element) {
}
}