Map element multiple locations

I made this prototype for a custom function that loads the data from a CPT called locations.

add_filter( 'bricks/element/settings', 'add_locations_to_map', 10, 2);
function add_locations_to_map( $settings, $element ) {
    if ( $element->name === 'map'  ) {
        
        $args = [ 
            'post_type' => 'locations',
			'posts_per_page' => '-1',
			'post_status'    => 'publish'
        ];  
        $posts_query = new WP_Query( $args );
        $posts = $posts_query->posts;
        
        $output = [];
        
        foreach ($posts as $key=>$p) {
            $location = [
                'id' =>  $p->ID,
                'address' => $p->google_address,
                'infoTitle' => $p->post_title
            ];
            $output[] = $location;
        }

        $settings['addresses'] = $output;
    }
    return $settings;
};

Not pretty and you will have to add more of the parameters to the addresses array, but it works.