Home › Forums › Calendar Products › Events Calendar PRO › Get Google Maps Link
- This topic has 8 replies, 2 voices, and was last updated 10 years, 11 months ago by
Brian.
-
AuthorPosts
-
May 29, 2015 at 10:04 am #966033
Rob
ParticipantHello.
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 ' '; } 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>';May 29, 2015 at 10:06 am #966034Rob
ParticipantA single event does display the full Google Maps link:
http://mobilemug.com/dev/event/third-event/(all events currently use the same Venue)
Thanks
May 29, 2015 at 2:45 pm #966167Brian
MemberHi,
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
May 29, 2015 at 3:02 pm #966173Rob
ParticipantThanks Brian. No-go.
There is nothing returned fromecho tribe_get_meta('tribe_event_venue_gmap_link');
Can this be called while in a tribe_get_events even though it’s venue info?May 30, 2015 at 12:30 pm #966234Brian
MemberOk 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
June 1, 2015 at 5:13 am #966360Rob
ParticipantThanks Brian.
That also returns nothing. We’re using tribe_get_events, is there something I’m missing?June 1, 2015 at 6:02 am #966367Brian
MemberI 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.
June 1, 2015 at 7:58 am #966389Rob
ParticipantThanks.
This got me close.
I needed$event_id = $event->ID;
than I was able to return the correct info.June 1, 2015 at 1:07 pm #966456Brian
MemberI 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!
-
AuthorPosts
- The topic ‘Get Google Maps Link’ is closed to new replies.
