class Spiderfying in Geolocation Field 8.3
Same name and namespace in other branches
- 8.2 modules/geolocation_google_maps/src/Plugin/geolocation/MapFeature/Spiderfying.php \Drupal\geolocation_google_maps\Plugin\geolocation\MapFeature\Spiderfying
Provides Spiderfying.
Plugin annotation
@MapFeature(
id = "spiderfying",
name = @Translation("Spiderfying"),
description = @Translation("Split up overlapping markers on click."),
type = "google_maps",
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\geolocation\MapFeatureBase implements ContainerFactoryPluginInterface, MapFeatureInterface
- class \Drupal\geolocation_google_maps\Plugin\geolocation\MapFeature\Spiderfying
- class \Drupal\geolocation\MapFeatureBase implements ContainerFactoryPluginInterface, MapFeatureInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of Spiderfying
1 string reference to 'Spiderfying'
- geolocation_google_maps.map_features.schema.yml in modules/
geolocation_google_maps/ config/ schema/ geolocation_google_maps.map_features.schema.yml - modules/geolocation_google_maps/config/schema/geolocation_google_maps.map_features.schema.yml
File
- modules/
geolocation_google_maps/ src/ Plugin/ geolocation/ MapFeature/ Spiderfying.php, line 18
Namespace
Drupal\geolocation_google_maps\Plugin\geolocation\MapFeatureView source
class Spiderfying extends MapFeatureBase {
/**
* {@inheritdoc}
*/
public static function getDefaultSettings() {
return [
'spiderfiable_marker_path' => base_path() . drupal_get_path('module', 'geolocation_google_maps') . '/images/marker-plus.svg',
'markersWontMove' => TRUE,
'markersWontHide' => FALSE,
'keepSpiderfied' => TRUE,
'ignoreMapClick' => FALSE,
'nearbyDistance' => 20,
'circleSpiralSwitchover' => 9,
'circleFootSeparation' => 23,
'spiralFootSeparation' => 26,
'spiralLengthStart' => 11,
'spiralLengthFactor' => 4,
'legWeight' => 1.5,
];
}
/**
* {@inheritdoc}
*/
public function getSettingsForm(array $settings, array $parents) {
$form['spiderfiable_marker_path'] = [
'#type' => 'textfield',
'#title' => $this
->t('Marker Path'),
'#description' => $this
->t('Set relative or absolute path to the image to be displayed while markers are spiderfiable. Tokens supported.'),
'#default_value' => $settings['spiderfiable_marker_path'],
];
$form['markersWontMove'] = [
'#type' => 'checkbox',
'#title' => $this
->t("Markers won't move"),
'#description' => $this
->t('If you know that you won’t be moving any of the markers you add to this instance, you can save memory by setting this to true.'),
'#default_value' => $settings['markersWontMove'],
];
$form['markersWontHide'] = [
'#type' => 'checkbox',
'#title' => $this
->t("Markers won't hide"),
'#description' => $this
->t('If you know that you won’t be hiding any of the markers you add to this instance, you can save memory by setting this to true.'),
'#default_value' => $settings['markersWontHide'],
];
$form['keepSpiderfied'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Keep spiderfied'),
'#description' => $this
->t('By default, the OverlappingMarkerSpiderfier works like Google Earth, in that when you click a spiderfied marker, the markers unspiderfy before any other action takes place. Setting this to true overrides this behavior.'),
'#default_value' => $settings['keepSpiderfied'],
];
$form['ignoreMapClick'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Ignore map click'),
'#description' => $this
->t('By default, clicking an empty spot on the map causes spiderfied markers to unspiderfy. Setting this option to true suppresses that behavior.'),
'#default_value' => $settings['ignoreMapClick'],
];
$form['nearbyDistance'] = [
'#type' => 'number',
'#title' => $this
->t('Nearby distance'),
'#description' => $this
->t('This is the pixel radius within which a marker is considered to be overlapping a clicked marker.'),
'#default_value' => $settings['nearbyDistance'],
];
$form['circleSpiralSwitchover'] = [
'#type' => 'number',
'#title' => $this
->t('Circle spiral switchover'),
'#description' => $this
->t('This is the lowest number of markers that will be fanned out into a spiral instead of a circle.'),
'#default_value' => $settings['circleSpiralSwitchover'],
];
$form['circleFootSeparation'] = [
'#type' => 'number',
'#title' => $this
->t('Circle foot separation'),
'#description' => $this
->t('Determines the positioning of markers when spiderfied out into a circle.'),
'#default_value' => $settings['circleFootSeparation'],
];
$form['spiralFootSeparation'] = [
'#type' => 'number',
'#title' => $this
->t('Spiral Foot Separation'),
'#description' => $this
->t('Determines the positioning of markers when spiderfied out into a spiral.'),
'#default_value' => $settings['spiralFootSeparation'],
];
$form['spiralLengthStart'] = [
'#type' => 'number',
'#title' => $this
->t('Spiral length start'),
'#default_value' => $settings['spiralLengthStart'],
];
$form['spiralLengthFactor'] = [
'#type' => 'number',
'#title' => $this
->t('Spiral length factor'),
'#default_value' => $settings['spiralLengthFactor'],
];
$form['legWeight'] = [
'#type' => 'number',
'#step' => '.1',
'#title' => $this
->t('Leg weight'),
'#description' => $this
->t('This determines the thickness of the lines joining spiderfied markers to their original locations.'),
'#default_value' => $settings['legWeight'],
];
return $form;
}
/**
* {@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,
'spiderfiable_marker_path' => $feature_settings['spiderfiable_marker_path'],
'markersWontMove' => $feature_settings['markersWontMove'],
'markersWontHide' => $feature_settings['markersWontHide'],
'keepSpiderfied' => $feature_settings['keepSpiderfied'],
'ignoreMapClick' => $feature_settings['ignoreMapClick'],
'nearbyDistance' => $feature_settings['nearbyDistance'],
'circleSpiralSwitchover' => $feature_settings['circleSpiralSwitchover'],
'circleFootSeparation' => $feature_settings['circleFootSeparation'],
'spiralFootSeparation' => $feature_settings['spiralFootSeparation'],
'spiralLengthStart' => $feature_settings['spiralLengthStart'],
'spiralLengthFactor' => $feature_settings['spiralLengthFactor'],
'legWeight' => $feature_settings['legWeight'],
],
],
],
],
],
]);
if (!empty($feature_settings['spiderfiable_marker_path'])) {
$path = \Drupal::token()
->replace($feature_settings['spiderfiable_marker_path'], $context);
$render_array['#attached']['drupalSettings']['geolocation']['maps'][$render_array['#id']]['spiderfying']['spiderfiable_marker_path'] = $path;
}
return $render_array;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MapFeatureBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
2 |
MapFeatureBase:: |
public | function |
Provide map feature specific settings ready to handover to JS. Overrides MapFeatureInterface:: |
|
MapFeatureBase:: |
public | function |
Provide a summary array to use in field formatters. Overrides MapFeatureInterface:: |
2 |
MapFeatureBase:: |
public | function |
Validate Feature Form. Overrides MapFeatureInterface:: |
5 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
Spiderfying:: |
public | function |
Alter render array. Overrides MapFeatureBase:: |
|
Spiderfying:: |
public static | function |
Provide a populated settings array. Overrides MapFeatureBase:: |
|
Spiderfying:: |
public | function |
Provide a generic map settings form array. Overrides MapFeatureBase:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |