Passing arguments in add_action inside search template

The footer doesn’t run in the global context, so the variable $map_vars is not in the correct scope.

To keep the variable and the callback in the same scope, you could use a class:

class Map_Var_Example
{
    public static $map_vars;

    public static function map_data()
    {
        var_dump( self::$map_vars );
    }
}

Map_Var_Example::$map_vars="Test";

add_action( 'wp_footer', array( 'Map_Var_Example', 'map_data' ), 10, 1 );