GoogleMaps.php in Address Map (& Directions) Link 8
Namespace
Drupal\address_map_link\Plugin\MapLinkFile
src/Plugin/MapLink/GoogleMaps.phpView source
<?php
namespace Drupal\address_map_link\Plugin\MapLink;
use Drupal\address\AddressInterface;
use Drupal\address_map_link\MapLinkBase;
use Drupal\Core\Url;
/**
* Provides a Google Maps link type.
*
* @MapLink(
* id = "google_maps",
* name = @Translation("Google Maps")
* )
*/
class GoogleMaps extends MapLinkBase {
/**
* Gets the map link url from an address.
*
* @param \Drupal\address\AddressInterface $address
* The address.
*
* @return \Drupal\Core\Url
* The Url.
*/
public function getAddressUrl(AddressInterface $address) {
return Url::fromUri('https://google.com/maps', [
'query' => [
'q' => $this
->addressString($address),
],
]);
}
}
Classes
Name | Description |
---|---|
GoogleMaps | Provides a Google Maps link type. |