You are here

public function GeoJSON::attached in Openlayers 7.3

Returns a list of attachments for building the render array.

Return value

array The attachments to add.

Overrides Base::attached

File

src/Plugin/Source/GeoJSON/GeoJSON.php, line 126
Source: GeoJson.

Class

GeoJSON
Class GeoJSON.

Namespace

Drupal\openlayers\Plugin\Source\GeoJSON

Code

public function attached() {
  $attached = parent::attached();
  $plugin = $this
    ->getPluginDefinition();
  $plugin['path'] = $this
    ->getClassDirectory();
  if ($this
    ->getOption('devMode')) {

    // @TODO Find a way how to do this just once per map / collection.
    $attached['library']['system.ui.dialog'] = array(
      'system',
      'ui.dialog',
    );
    $attached['library']['system.jquery.cookie'] = array(
      'system',
      'jquery.cookie',
    );
    $attached['js'][$plugin['path'] . '/js/geojson_dev.js']['weight'] = Config::get('openlayers.js_css.weight') + 1;
  }
  else {
    unset($attached['js'][$plugin['path'] . '/js/geojson_dev.js']);
    unset($attached['css'][$plugin['path'] . '/css/geojson_dev.css']);
  }
  return $attached;
}