Get Google Maps Link

Home Forums Calendar Products Events Calendar PRO Get Google Maps Link

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #966033
    Rob
    Participant

    Hello.
    We have built a custom display of events for our site. We are using tribe_get_events then a foreach loop to display each event. In the foreach loop, we successfully display tribe_get_address and tribe_get_start_date, but are not able to do tribe_get_map_link_html.

    tribe_get_map_link_html returns this (no href value):
    <a class="tribe-events-gmap" href="" title="Click to view a Google Map" target="_blank">+ Google Map</a>

    We also tried tribe_get_map_link but it returns nothing.

    We want to return just the url for the map so that we can wrap it in our own <a> tag. How can we get the Google Maps link from the event?

    Our full code:

    $today = strtotime('-5 hours');
    						$daycount = 0;
    						/* echo date("n/j D G:i e", $today); */
    						echo '<div class="cal-toggle"><button class="cal-toggle-button">Click To View Our Weekly Schedule<div class="arrow-down red"></div></button></div>
    						<div class="mm-cal-wrapper">
    					                        <div class="mm-cal-container">
    					                        <div class="mm-cal-grid-wrapper">
    					                        <ul class="mm-cal-grid">';
    						while($daycount<14) {
    							/* each day */
    							echo '<li class="mm-cal-day">';
    							echo '<span class="mm-cal-day-date">' .date("n/j D", strtotime('+'.$daycount.' day')). '</span>';
    							echo '<ul class="mm-cal-events">';
    							$events = tribe_get_events( array(
    								 'start_date'	=> date( 'Y-m-d H:i:s', strtotime('+'.$daycount.' day') ),
    								 'end_date'		=> date( 'Y-m-d H:i:s', strtotime('+'.++$daycount.' day') ),
    								 'eventDisplay'	=> 'custom'
    							));
    							if ( empty( $events ) ) {
    							    echo '&nbsp;';
    							}
    							else foreach( $events as $event ) {
    							    $locationname = tribe_get_address( $event );
    							    $locationlink = tribe_get_map_link_html( $event );
    							    echo '<li class="mm-cal-event"><span class="mm-cal-event-detail time">';
    							    echo tribe_get_start_date($event) . '-' . tribe_get_end_date($event);
    							    echo '</span><br><span>';
    							    echo $locationname;
    							    echo $locationlink;
    							    echo '</span></li>';
    							}
    							/* end each day */ 
    							echo '</ul></li>';	
    						}
    						echo ' </ul>
                            
                            </div></div></div>';
    #966034
    Rob
    Participant

    A single event does display the full Google Maps link:
    http://mobilemug.com/dev/event/third-event/

    (all events currently use the same Venue)

    Thanks

    #966167
    Brian
    Member

    Hi,

    Thanks for using our plugins.

    I can help out here.

    This is not quite what you are looking for, but this function creates a link to the Google Map. (adds the link markup)

    echo tribe_get_meta('tribe_event_venue_gmap_link');

    Does that work for you?

    Cheers

    #966173
    Rob
    Participant

    Thanks Brian. No-go.
    There is nothing returned from echo tribe_get_meta('tribe_event_venue_gmap_link');
    Can this be called while in a tribe_get_events even though it’s venue info?

    #966234
    Brian
    Member

    Ok I dug a little deeper and found this:

    <?php echo tribe_get_map_link(); ?>

    That showed just a Google map link in the single event template.

    That may work for you.

    Cheers

    #966360
    Rob
    Participant

    Thanks Brian.
    That also returns nothing. We’re using tribe_get_events, is there something I’m missing?

    #966367
    Brian
    Member

    I only tested in the single template and it worked there, but maybe you can directly pass a event id into it to work.

    You can try passing the event id into it like this:

    $event_id = get_the_ID();

    echo tribe_get_map_link( $event_id );

    If that does not work another option around this is to use this function:

    $venue_id = tribe_get_venue_id( $event_id );

    And then use the meta fields from the venue as outlined here:

    https://gist.github.com/jesseeproductions/c2df90a56827dae990a0

    To build a custom Google Maps Link.

    Otherwise that is all we have for this and there is not much else we can provide on customizations.

    #966389
    Rob
    Participant

    Thanks.
    This got me close.
    I needed $event_id = $event->ID;
    than I was able to return the correct info.

    #966456
    Brian
    Member

    I am glad to see you were able to figure it out.

    I am going to go ahead and close this ticket. If you have a similar issue or another in the future, please do not hesitate to create a new ticket.

    Thanks!

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Get Google Maps Link’ is closed to new replies.