abstract class Map in Openlayers 7.3
Class Map.
Hierarchy
- class \Drupal\openlayers\Types\Base extends \Drupal\Component\Plugin\PluginBase implements ObjectInterface
- class \Drupal\openlayers\Types\Map implements MapInterface
Expanded class hierarchy of Map
31 string references to 'Map'
- Base::getParents in src/
Types/ Base.php - Returns an array with the maps this object is attached on.
- MapSwitcher::postBuild in modules/
openlayers_library/ src/ Plugin/ Component/ MapSwitcher/ MapSwitcher.php - Invoked after an objects render array is built.
- OLMap::optionsForm in src/
Plugin/ Map/ OLMap/ OLMap.php - @TODO What is this return? If it is the form, why is form by reference?
- openlayers.services.yml in ./
openlayers.services.yml - openlayers.services.yml
- openlayers::options_form in modules/
openlayers_boxes/ plugins/ boxes/ openlayers.php - Provide options to configure content.
File
- src/
Types/ Map.php, line 14 - Class Map.
Namespace
Drupal\openlayers\TypesView source
abstract class Map extends Base implements MapInterface {
/**
* {@inheritdoc}
*
* @return MapInterface
* The Map object.
*/
public function addLayer(LayerInterface $layer) {
return $this
->addObject($layer);
}
/**
* {@inheritdoc}
*
* @return MapInterface
* The Map object.
*/
public function addControl(ControlInterface $control) {
return $this
->addObject($control);
}
/**
* {@inheritdoc}
*
* @return MapInterface
* The Map object.
*/
public function addInteraction(InteractionInterface $interaction) {
return $this
->addObject($interaction);
}
/**
* {@inheritdoc}
*
* @return MapInterface
* The Map object.
*/
public function addComponent(ComponentInterface $component) {
return $this
->addObject($component);
}
/**
* {@inheritdoc}
*
* @return MapInterface
* The Map object.
*/
public function removeLayer($layer_id) {
return $this
->removeObject($layer_id);
}
/**
* {@inheritdoc}
*
* @return MapInterface
* The Map object.
*/
public function removeComponent($component_id) {
return $this
->removeObject($component_id);
}
/**
* {@inheritdoc}
*
* @return MapInterface
* The Map object.
*/
public function removeControl($control_id) {
return $this
->removeObject($control_id);
}
/**
* {@inheritdoc}
*
* @return MapInterface
* The Map object.
*/
public function removeInteraction($interaction_id) {
return $this
->removeObject($interaction_id);
}
/**
* {@inheritdoc}
*/
public function attached() {
$attached = parent::attached();
$settings = $this
->getCollection()
->getJS();
$settings['map'] = array_shift($settings['map']);
$attached['js'][] = array(
'data' => array(
'openlayers' => array(
'maps' => array(
$this
->getId() => $settings,
),
),
),
'type' => 'setting',
);
return $attached;
}
/**
* {@inheritdoc}
*/
public function getJS() {
$js = parent::getJS();
unset($js['opt']['capabilities']);
return $js;
}
/**
* {@inheritdoc}
*/
public function render() {
$build = $this
->build();
return drupal_render($build);
}
/**
* {@inheritdoc}
*/
public function build(array $build = array()) {
$map = $this;
// If this is an asynchronous map flag it as such.
if ($asynchronous = $this
->isAsynchronous()) {
$map
->setOption('async', $asynchronous);
}
if (!$map
->getOption('target', FALSE)) {
$this
->setOption('target', $this
->getId());
}
// Transform the options into objects.
$map
->getCollection()
->import($map
->optionsToObjects());
// Run prebuild hook to all objects who implements it.
$map
->preBuild($build, $map);
$capabilities = array();
if ((bool) $this
->getOption('capabilities', FALSE) === TRUE) {
$items = array_values($this
->getOption(array(
'capabilities',
'options',
'table',
), array()));
array_walk($items, 'check_plain');
$capabilities = array(
'#weight' => 1,
'#type' => $this
->getOption(array(
'capabilities',
'options',
'container_type',
), 'fieldset'),
'#collapsed' => TRUE,
'#collapsible' => TRUE,
'#attached' => array(
'library' => array(
array(
'system',
'drupal.collapse',
),
),
),
/*
'#attributes' => array(
'class' => array(
$this->getOption(array(
'capabilities',
'options',
'collapsible',
), TRUE) ? 'collapsible' : '',
$this->getOption(array(
'capabilities',
'options',
'collapsed',
), TRUE) ? 'collapsed' : '',
),
),
*/
'#title' => $this
->getOption(array(
'capabilities',
'options',
'title',
), NULL),
'#description' => $this
->getOption(array(
'capabilities',
'options',
'description',
), NULL),
array(
'#theme' => 'item_list',
'#items' => $items,
'#title' => '',
'#type' => 'ul',
),
);
}
$build = array(
'#theme' => 'openlayers',
'#map' => $map,
'#attached' => $map
->getCollection()
->getAttached(),
'map_prefix' => array(),
'map_suffix' => array(),
'capabilities' => $capabilities,
);
$map
->postBuild($build, $map);
return $build;
}
/**
* {@inheritdoc}
*/
public function optionsToObjects() {
$import = array();
// TODO: Simplify this.
// Add the objects from the configuration.
foreach (Openlayers::getPluginTypes(array(
'map',
)) as $weight_type => $type) {
foreach ($this
->getOption($type . 's', array()) as $weight => $object) {
if (!$this
->getCollection()
->getObjectById($type, $object)) {
if ($merge_object = Openlayers::load($type, $object)) {
$merge_object
->setWeight($weight_type . '.' . $weight);
$import[$type . '_' . $merge_object
->getMachineName()] = $merge_object;
}
}
}
}
foreach ($this
->getCollection()
->getFlatList() as $object) {
$import[$object
->getType() . '_' . $object
->getMachineName()] = $object;
}
return $import;
}
/**
* {@inheritdoc}
*/
public function setSize(array $size = array()) {
list($width, $height) = array_values($size);
return $this
->setOption('width', $width)
->setOption('height', $height);
}
/**
* {@inheritdoc}
*/
public function getSize() {
return array(
$this
->getOption('width'),
$this
->getOption('height'),
);
}
/**
* {@inheritdoc}
*/
public function setTarget($target) {
return $this
->setOption('target', $target);
}
/**
* {@inheritdoc}
*/
public function getTarget() {
return $this
->getOption('target');
}
/**
* {@inheritdoc}
*/
public function isAsynchronous() {
return array_reduce($this
->getDependencies(), function ($res, $obj) {
return $res + (int) $obj
->isAsynchronous();
}, 0);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Base:: |
protected | property | Holds all the attachment used by this object. | 6 |
Base:: |
protected | property | Holds the Collection object. | |
Base:: |
protected | property | A unique ID for the object. | |
Base:: |
protected | property | The array containing the options. | 6 |
Base:: |
public | function |
Add an object into the collection of the parent object. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Remove an option. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Defines dependencies. Overrides ObjectInterface:: |
3 |
Base:: |
public | function |
Returns the path to the plugin directory. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Returns the path to the class file. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Return the Collection object linked to the object. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Return the object configuration. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Return all the dependencies objects of the parent object. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Return the description of the object. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Return an object, CTools Exportable. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Return the Factory Service of the object. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Return the object unique ID. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Return the unique machine name of the object. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Return the human name of the object. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Return an array of OL objects indexed by their type. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Returns an option. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Return the options array. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Returns an array with the maps this object is attached on. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Return the description of the object's plugin. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Return the module that provides this plugin. Overrides ObjectInterface:: |
|
Base:: |
public | function |
The type of this object. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Get the weight of an object. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Refresh string translations. Overrides ObjectInterface:: |
1 |
Base:: |
public | function |
Initializes the object. Overrides ObjectInterface:: |
2 |
Base:: |
public | function |
Initializes the Collection,
Import objects from options,
Import the current object. Overrides ObjectInterface:: |
|
Base:: |
public | function |
@TODO What is this return? If it is the form, why is form by reference? Overrides ObjectInterface:: |
54 |
Base:: |
public | function |
Submit callback for the options form. Overrides ObjectInterface:: |
11 |
Base:: |
public | function |
Validation callback for the options form. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Invoked after an objects render array is built. Overrides ObjectInterface:: |
13 |
Base:: |
public | function |
Invoked before an objects render array is built. Overrides ObjectInterface:: |
4 |
Base:: |
public | function |
Remove an object from the collection. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Reset the object's Collection. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Set the Factory Service of the object. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Set the object ID. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Set an option. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Set the options array. Overrides ObjectInterface:: |
|
Base:: |
public | function |
Set the weight of an object. Overrides ObjectInterface:: |
|
Map:: |
public | function |
Overrides MapInterface:: |
|
Map:: |
public | function |
Overrides MapInterface:: |
|
Map:: |
public | function |
Overrides MapInterface:: |
|
Map:: |
public | function |
Overrides MapInterface:: |
|
Map:: |
public | function |
Returns a list of attachments for building the render array. Overrides Base:: |
1 |
Map:: |
public | function |
Build render array of a map. Overrides MapInterface:: |
|
Map:: |
public | function |
!Attention! This function will remove any option that is named after a
plugin type e.g.: layers, controls, styles, interactions, components . Overrides Base:: |
|
Map:: |
public | function |
Return the size of the map. Overrides MapInterface:: |
|
Map:: |
public | function |
Get the target ID in which this map is rendered. Overrides MapInterface:: |
|
Map:: |
public | function |
Whether or not this object has to be processed asynchronously. Overrides Base:: |
|
Map:: |
public | function |
Return a flat array containing Openlayers Objects from the options array. Overrides Base:: |
|
Map:: |
public | function |
Overrides MapInterface:: |
|
Map:: |
public | function |
Overrides MapInterface:: |
|
Map:: |
public | function |
Overrides MapInterface:: |
|
Map:: |
public | function |
Overrides MapInterface:: |
|
Map:: |
public | function |
Render a build array into HTML. Overrides MapInterface:: |
|
Map:: |
public | function |
Set the size of the map. Overrides MapInterface:: |
|
Map:: |
public | function |
Set the target element to render this map into. Overrides MapInterface:: |