You are here

class Geolocation in Geolocation Field 8

Same name in this branch
  1. 8 src/Plugin/Geocoder/Dumper/Geolocation.php \Drupal\geolocation\Plugin\Geocoder\Dumper\Geolocation
  2. 8 src/Plugin/Geocoder/Field/Geolocation.php \Drupal\geolocation\Plugin\Geocoder\Field\Geolocation
Same name and namespace in other branches
  1. 8.2 src/Plugin/Geocoder/Dumper/Geolocation.php \Drupal\geolocation\Plugin\Geocoder\Dumper\Geolocation

Provides a geolocation geocoder dumper plugin.

Plugin annotation


@GeocoderDumper(
  id = "geolocation",
  name = "Geolocation"
)

Hierarchy

  • class \Drupal\geolocation\Plugin\Geocoder\Dumper\Geolocation extends \Drupal\geocoder\DumperBase

Expanded class hierarchy of Geolocation

5 string references to 'Geolocation'
geolocation.info.yml in ./geolocation.info.yml
geolocation.info.yml
geolocation_demo.info.yml in modules/geolocation_demo/geolocation_demo.info.yml
modules/geolocation_demo/geolocation_demo.info.yml
geolocation_google_places_api.info.yml in modules/geolocation_google_places_api/geolocation_google_places_api.info.yml
modules/geolocation_google_places_api/geolocation_google_places_api.info.yml
views.view.geolocation_common_map_ajax_test.yml in tests/modules/geolocation_test_views/test_views/views.view.geolocation_common_map_ajax_test.yml
tests/modules/geolocation_test_views/test_views/views.view.geolocation_common_map_ajax_test.yml
views.view.geolocation_proximity_test.yml in tests/modules/geolocation_test_views/test_views/views.view.geolocation_proximity_test.yml
tests/modules/geolocation_test_views/test_views/views.view.geolocation_proximity_test.yml

File

src/Plugin/Geocoder/Dumper/Geolocation.php, line 16

Namespace

Drupal\geolocation\Plugin\Geocoder\Dumper
View source
class Geolocation extends DumperBase {

  /**
   * {@inheritdoc}
   */
  public function dump(Address $address) {
    $data = $address
      ->toArray();
    $lat = $data['latitude'];
    $lng = $data['longitude'];
    unset($data['latitude'], $data['longitude'], $data['bounds']);
    return [
      'lat' => $lat,
      'lng' => $lng,
      'lat_sin' => sin(deg2rad($lat)),
      'lat_cos' => cos(deg2rad($lat)),
      'lng_rad' => deg2rad($lng),
      'data' => $data,
    ];
  }

}

Members