I need to get an array from the wordpress database

Is this what you are asking for? Use it after the code you posted to create posts in loop and use thier ids to update meta fields. Replace “post_type” with your custom post type.

foreach ($markers as $marker){
    $post_id = wp_insert_post(array(
        "post_title" => "something",
        "post_type" => "your-type",
        "post_status" => "publish", //by default they are drafts
        // etc.
    ));
    update_post_meta($post_id, "latitude", $marker['lat']);
    update_post_meta($post_id, "longitude", $marker['long']);
}

After that you can get those fields by using get_post_meta()