You are here

MapTilt.php in Geolocation Field 8.2

File

modules/geolocation_google_maps/src/Plugin/geolocation/MapFeature/MapTilt.php
View source
<?php

namespace Drupal\geolocation_google_maps\Plugin\geolocation\MapFeature;

use Drupal\geolocation\MapFeatureBase;
use Drupal\Core\Render\BubbleableMetadata;

/**
 * Provides map tilt.
 *
 * @MapFeature(
 *   id = "map_disable_tilt",
 *   name = @Translation("Disable Map Tilt"),
 *   description = @Translation("Disable 45° tilted perspective view available for certain locations."),
 *   type = "google_maps",
 * )
 */
class MapTilt extends MapFeatureBase {

  /**
   * {@inheritdoc}
   */
  public function alterMap(array $render_array, array $feature_settings, array $context = []) {
    $render_array = parent::alterMap($render_array, $feature_settings, $context);
    $render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
      'library' => [
        'geolocation_google_maps/mapfeature.' . $this
          ->getPluginId(),
      ],
      'drupalSettings' => [
        'geolocation' => [
          'maps' => [
            $render_array['#id'] => [
              $this
                ->getPluginId() => [
                'enable' => TRUE,
              ],
            ],
          ],
        ],
      ],
    ]);
    return $render_array;
  }

}

Classes

Namesort descending Description
MapTilt Provides map tilt.