Map view: show venues instead of events?

Home Forums Welcome! Pre-Sales Questions Map view: show venues instead of events?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1150726
    Trevor
    Guest

    One important feature I’m looking for with a event/calendar/map plugin is the ability to show all venues on the map, rather than events (which are seasonal and constantly changing). Can the map version of your pro calendar do this?

    Or barring that, the ability to show all events on the map rather than just upcoming events? I prefer my customers to have the ability to always see on the map the total amount of locations we visit, even if the event has passed.

    #1150773
    Nico
    Member

    Hi there Trevor,

    Thanks for getting in touch and for your interest in our plugins šŸ™‚

    Actually both things are possible in a way! Let me touch both questions real quick:

    One important feature I’m looking for with a event/calendar/map plugin is the ability to show all venues on the map, rather than events (which are seasonal and constantly changing). Can the map version of your pro calendar do this?

    I recently created a shortcode to show the venues in a Google Map instance for a customer. This was tested using Events Calendar PRO so I’m not sure if it will still work without it. After adding the following snippet to your theme’s (or child theme’s) functions.php file the shortcode will be available:

    /* Tribe [tribe_venue_map] shortcode sample */
    function tribe_venue_map_logic ( $atts ){

    $url = apply_filters( 'tribe_events_google_maps_api', 'https://maps.google.com/maps/api/js' );
    $url = $url . '&callback=tribe_venue_map';

    wp_enqueue_script( 'tribe_events_google_maps_api', $url, array(), false, true );
    wp_enqueue_script( 'jquery' );

    add_action('wp_footer', function () { ?>
    <style>
    #tribe-venue-map {
    width: 100%;
    height: 400px;
    }
    </style>
    <script>
    function tribe_venue_map() {

    var map = new google.maps.Map(document.getElementById('tribe-venue-map'), {
    center: {lat: 34.5133, lng: -94.1629},
    zoom: 2
    });

    <?php

    $venues = get_posts( array( 'post_type' => Tribe__Events__Main::VENUE_POST_TYPE, 'posts_per_page' => -1) );

    foreach ( $venues as $venue ) {

    $coordinates = tribe_get_coordinates ( $venue->ID );

    if ( $coordinates['lat'] != 0 && $coordinates['lng'] != 0 ) { ?>

    window['marker_' + <?php echo $venue->ID; ?>] = new google.maps.Marker({
    position: {lat: <?php echo $coordinates['lat']; ?>, lng: <?php echo $coordinates['lng']; ?>},
    map: map,
    title: "<?php echo $venue->post_title; ?>"
    });

    window['info_' + <?php echo $venue->ID; ?>] = new google.maps.InfoWindow({
    content: "<?php echo $venue->post_title; ?>"
    });

    window['marker_' + <?php echo $venue->ID; ?>].addListener('click', function() {
    window['info_' + <?php echo $venue->ID; ?>].open(map, window['marker_' + <?php echo $venue->ID; ?>]);
    });

    <?php
    }
    } ?>
    }

    </script>

    <?php });

    return '<div id="tribe-venue-map"></div>';

    }
    add_shortcode( 'tribe_venue_map', 'tribe_venue_map_logic' );

    Or barring that, the ability to show all events on the map rather than just upcoming events? I prefer my customers to have the ability to always see on the map the total amount of locations we visit, even if the event has passed.

    This is possible as well by hi-jacking the map view query and setting the posts per page parameter to be unlimited.

    Please let me know if the above answers your questions,
    Best,
    Nico

    #1159361
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Map view: show venues instead of events?’ is closed to new replies.