You are here

public function Photon::formAttachGeocoder in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 modules/geolocation_leaflet/src/Plugin/geolocation/Geocoder/Photon.php \Drupal\geolocation_leaflet\Plugin\geolocation\Geocoder\Photon::formAttachGeocoder()

Attach geocoding logic to input element.

Parameters

array $render_array: Form containing the input element.

string $element_name: Name of the input element.

Return value

array|null Updated form element or NULL.

Overrides GeocoderBase::formAttachGeocoder

File

modules/geolocation_leaflet/src/Plugin/geolocation/Geocoder/Photon.php, line 65

Class

Photon
Provides the Photon.

Namespace

Drupal\geolocation_leaflet\Plugin\geolocation\Geocoder

Code

public function formAttachGeocoder(array &$render_array, $element_name) {
  parent::formAttachGeocoder($render_array, $element_name);
  $settings = $this
    ->getSettings();
  $render_array['#attached'] = BubbleableMetadata::mergeAttachments(empty($render_array['#attached']) ? [] : $render_array['#attached'], [
    'library' => [
      'geolocation_leaflet/geocoder.photon',
    ],
    'drupalSettings' => [
      'geolocation' => [
        'geocoder' => [
          $this
            ->getPluginId() => [
            'locationPriority' => [
              'lat' => $settings['location_priority']['lat'],
              'lon' => $settings['location_priority']['lng'],
            ],
          ],
        ],
      ],
    ],
  ]);
}