Create an openlayers.api.php file to document hooks provided by Openlayers.

Original description:

Is there any way to dynamically alter objects in the new Openlayers 3.x? In 2.x, there was hook_openlayers_map_preprocess_alter() for altering a map before it is rendered.

For my specific use case, I would like to provide a map in module A, and alter it in module B (so that module B can be turned on/off, and the alteration will do the same).

Comments

m.stenta’s picture

Ah ha... I found two drupal_alter()s:

In \Drupal\openlayers\Types\Object->preBuild()

drupal_alter('openlayers_object_preprocess', $build, $this);

And ...->postBuild()

drupal_alter('openlayers_object_postprocess', $build, $this);

I will give that a try.

Should there be an openlayers.API.php to document these? Are there other hooks or alters available?

Pol’s picture

Assigned: Unassigned » Pol

Hello,

Yes indeed, you have the preBuild() and postBuild() methods, but you also have the hook_openlayers_object_postprocess_alter() and hook_openlayers_object_preprocess_alter().

And yes this should be defined in a .api.php file...

m.stenta’s picture

Title: How to alter objects dynamically? » Document hooks in openlayers.api.php
Category: Support request » Task
Issue summary: View changes

(Updating issue title and description.)

m.stenta’s picture

Status: Active » Closed (fixed)

I think this is done.