I'm writing a module that will alter map zoom level and map center based on argument from url. But I cant figure out how the hook_openlayers_map_alter(&$map = array()) works, I'v tried to test this hook with:

function openlayers_mapalter_openlayers_map_alter(&$map = array()) {

    $map->center['initial']['zoom'] = '1';


but it has no effect on maps. What is the proper way to call this hook?

2 Answers 2


have you tried using drupal_message to make sure it's being called?

Or calling the hook_openlayers_map_alter() function and using map as an array like so:

function hook_openlayers_map_alter(&$map = array()) {
    $map['center'] => array( 'lat' => '0',
                             'lon' => '0',
                             'zoom' => '2'



You have to clear cache to make the hook works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.