How can I get an array of all IDs from the current queried object?

You are overwriting $post_ids variable on every while loop, never collecting them.

That can be solved using

$post_ids = array();

while (have_posts()) : the_post();

  $post_ids[] = get_the_ID();

endwhile;

var_dump($post_ids); // this is an array of ids

However there is simpler way, you can skip the whle cycle and simply run:

if( function_exists( 'wpseo_local_show_map' ) && have_posts() ) {

  // this is an array of ids
  $post_ids = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ); 

  $params = array(
    'id' => $post_ids,
    'echo' => true,
    'width' => 425,
    'height' => 350,
    'zoom' => 10,
    'show_route' => true
  );
  wpseo_local_show_map( $params );
}