Using WordPress custom post type to display StoryMapJS

what happens if you create the array first and then add to it in the loop. Right now you’re not adding to an array, you just keep creating it.

post_name;
$args=array(
‘post_type’ => ‘storymap_event’,
‘posts_per_page’ => -1
);
?>

        <div id="mapdiv" style="width: 100%; height: 600px;"></div>

        <?php $my_query = null;
        $my_query = new WP_Query($args); $i=0;

        $sm_array_slides = array();
        if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); $i++;
            $title = get_the_title();
            $excerpt = get_the_excerpt();
            $thumb_id = get_post_thumbnail_id();
            $thumbnail = wp_get_attachment_image_src($thumb_id,'', true);
            $latitude = intval(get_post_meta($post->ID, 'wpcf-latitude', true));
            $longitude = intval(get_post_meta($post->ID, 'wpcf-longitude', true));
            $caption = get_post_meta($post->ID, 'wpcf-image-caption', true);
            $credit = get_post_meta($post->ID, 'wpcf-image-credit', true);
            if ( get_post_meta($post->ID, 'wpcf-image-credit', true )) { $overview = 'overview'; } else { $overview = ''; }

            $sm_array_slides [] = array (
                $i => 
                  array (
                    'text' => 
                    array (
                      'headline' => $title,
                      'text' => $excerpt
                    ),
                    'location' => 
                    array (
                      'name' => 'Lime street',
                      'lat' => 53.407615,
                      'lon' => -2.977302,
                      'zoom' => 10,
                      'line' => true,
                    ),
                    'media' => 
                    array (
                      'url' => 'https://www.youtube.com/watch?v=CCGTR-Oa50Q',
                      'caption' => 'Example video',
                    ),
                  ),
            );

            endwhile; } wp_reset_query();

            $sm_array = array (
              'storymap' => 
              array (
                'slides' => $sm_array_slides
              ),
            );

            ?>

            <?php $json = json_encode($sm_array);?>

            <script type="text/javascript">
            var storymap_data = <?php echo $json; ?>;
            var storymap_options = {};
            var storymap = new VCO.StoryMap('mapdiv', storymap_data, storymap_options);
            window.onresize = function(event) {
                storymap.updateDisplay(); // this isn't automatic
            }
        </script> 

you may need to pull the extra array ( out on this line:

$sm_array_slides [] = array ( (and don’t forget the trailing ))

But i don’t know the array format your map is looking for so i didn’t remove it in my code.