Google map not displaying

Home Forums Calendar Products Events Calendar PRO Google map not displaying

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1008557
    Mitch
    Participant

    Hello I’m having issues with getting the maps diplaying on my website acrf.com.au eg:

    https://acrf.com.au/event/blue-september/

    Instead of the map displaying the following error appears:

    Warning: Invalid argument supplied for foreach() in /home/devacrfc/public_html/wp-content/themes/Corsa-child/tribe-events/single-event.php on line 167

    The site is not using the pro version, however I have since purchased the pro plugin but am hesitant to change the current setup before attempting to resolve this issue first.

    #1008589
    Brian
    Member

    Hi,

    Sorry for the issues you are having. I can help out.

    It appears you have a custom event template in your theme and something about it is not quick correct.

    Please check in your theme this template:

    /wp-content/themes/Corsa-child/tribe-events/single-event.php

    And on line 167 compare that to the single-event.php template that ships with the plugin here:

    the-events-calendar/src/views/single-event.php

    Let me know what you find out.

    Thanks

    #1008761
    Mary Correia-Moreno
    Participant

    Hi Mitch,

    I had the same problem [my maps weren’t showing up at all]. If you have the plugin Root Relative URLS installed; try disabling that and reloading your page. Once I turned that plugin off my maps worked once again

    hope that helps!

    #1008815
    Brian
    Member

    Hi William thanks for the insight.

    #1009875
    Mitch
    Participant

    @william thank you but that plugin doesn’t exist on my site.

    Thank you Brian I will try this.

    #1009878
    Mitch
    Participant

    Hi Brian, I have compared single-event.php on the live site with the version from https://wordpress.org/plugins/the-events-calendar/. There are significant differences in the code as the existing developer appears to have adjusted the template.

    The original source doesn’t appear to have reference to Google maps. I do have file comparison tools, and the next step would be for me to start cutting and pasting code from one to the other, however perhaps with the code shown below the issue may stand out to you assuming you are more familiar with how the events calendar works? Any help greatly appreciated 🙂

    Code comparions below:

    Custom

    <?php
    /**
     * Single Event Template
     * A single event. This displays the event title, description, meta, and
     * optionally, the Google map for the event.
     * 
     * Override this template in your own theme by creating a file at [your-theme]/tribe-events/single-event.php
     *
     * @package TribeEventsCalendar
     * @since  2.1
     * @author Modern Tribe Inc.
     *
     */
    
    if ( !defined('ABSPATH') ) { die('-1'); }
    
    $event_id = get_the_ID();
    
    ?>
    
    <div class="body-container body-page">
    	<div class="container">		
    		<div class="spacer40 visible-lg visible-md visible-sm"></div>
    
    	<!-- <p class="tribe-events-back"><a href="<?php //echo tribe_get_events_link() ?>"> <?php //_e( '&laquo; All Events', 'tribe-events-calendar' ) ?></a></p> -->
    
    	<!-- Notices -->
    	<?php tribe_events_the_notices() ?>
    	
    	<div class="col-md-12">
    			<div class="event-title">
    				<div class="col-md-1 col-sm-2 col-xs-3 single-event-date">
    					<?php //$date = tribe_events_event_schedule_details( $event_id, '', ''); ?>
    					<?php
    					// $date = tribe_get_start_date();
    					// $patterns = array();
    					// $patterns[0] = '/,/';
    					// $replacements = array();
    					// $replacements[0] = '';
    					// $edate = preg_replace($patterns, $replacements, $date);
    					// $pieces = explode(" ", $edate);
    					// $m = $pieces[0];
    					// $emonth = substr($m, 0, 3);
    					//echo $pieces[1]; // piece2
    					?>
    					<div class="date">
    						<div class="month">
    							<?php echo tribe_get_start_date( $post->ID, false, 'M' ); ?>
    						</div>
    						<div class="day"><?php echo tribe_get_start_date( $post->ID, false, 'd' ); ?> </div>
    					</div>
    				</div>	
    
    		
    				<!-- <div class="padded-textgreen-left padded-lborder-w30 padded-marginb30 text-capitalize">
    					<h1 class="padded-font24"><strong><?php// the_title(); ?></strong></h1>
    				</div> -->
    				
    				<div class="padded-textgreen-left padded-lborder-w20 padded-marginb10 text-capitalize pull-left">
    					<h1 class="padded-font24"><strong><?php the_title(); ?></strong></h1>
    				</div>
    			<div class="cf"></div>
    		</div>
    	</div>
    	
    
    	<div class="tribe-events-schedule updated published tribe-clearfix">
    		<?php //echo tribe_events_event_schedule_details( $event_id, '<h3>', '</h3>'); ?>
    
    		<?php  if ( tribe_get_cost() ) :  ?>
    			<span class="tribe-events-divider">|</span>
    			<span class="tribe-events-cost"><?php echo tribe_get_cost( null, true ) ?></span>
    		<?php endif; ?>
    	</div>
    
    	<!-- Event header -->
    	<div id="tribe-events-header" <?php tribe_events_the_header_attributes() ?>>
    		<!-- Navigation -->
    		<h3 class="tribe-events-visuallyhidden"><?php _e( 'Event Navigation', 'tribe-events-calendar' ) ?></h3>
    		<ul class="tribe-events-sub-nav">
    			<li class="tribe-events-nav-previous"><?php tribe_the_prev_event_link( '<span>&laquo;</span> %title%' ) ?></li>
    			<li class="tribe-events-nav-next"><?php tribe_the_next_event_link( '%title% <span>&raquo;</span>' ) ?></li>
    		</ul><!-- .tribe-events-sub-nav -->
    	</div><!-- #tribe-events-header -->
    
    	<?php while ( have_posts() ) :  the_post(); ?>
    		<div id="post-<?php the_ID(); ?>" <?php post_class('vevent event-individual-content content'); ?>>
    
    			<div class="col-md-4 three-col first-col">
    				<!-- Event featured image -->
    				<?php echo tribe_event_featured_image(); ?>
    				<h2>Details</h2>
    				<div class="table">
    					<div class="table-row">
    						<div class="table-cell">
    							<p><strong>Date:</strong></p>
    						</div>
    						<div class="table-cell">
    							<p><?php echo tribe_get_start_date( $post->ID, false, 'M d, Y' ); ?> </p>
    						</div>
    					</div>
    					<div class="table-row">
    						<div class="table-cell">
    							<p><strong>Tags:</strong></p>
    						</div>
    						<div class="table-cell">
    							<p>
    								<?php
    							$posttags = get_the_tags();
    							$t= "No tags for this post.";
    							if ($posttags) {
    							  foreach($posttags as $tag) {
    							  	$tags .= $tag->name . ', ';
    							  }
    							  $t = substr($tags, 0, -2);
    							  echo $t;
    							}
    							?>
    							</p>
    
    						</div>
    					</div>
    					<?php
    						$wsite=tribe_get_event_website_link();
    
    						$wsite=trim($wsite);
    						if(!empty($wsite) || $wsite !=''){
    					?>
    					<div class="table-row eventwsite">
    						<div class="table-cell">
    							<p><strong>Website:</strong></p>
    						</div>
    						<div class="table-cell">
    							<p><?php echo $wsite; ?></p>
    						</div>
    					</div>
    					<?php
    						}
    					?>
    				</div>
    			</div>
    
    			<div class="col-md-4 three-col second-col">
    				<?php the_content(); ?>
    			</div>
    
    			<div class="col-md-4 three-col third-col">
    				<?php echo tribe_get_embedded_map($post_id, 100, 800, false); ?>
    				<p><strong><a href="<?php echo tribe_get_map_link(); ?>" target="_blank">+ Google Map</a></strong></p>
    				<span class="spacer20"></span>
    				<h2>Venue</h2>
    
    				<p>
    					<?php
    						$state='';
    						$ptermargs=array(
    										'slug' => 'event-locations',
    										'hide_empty' => false,
    								  );
    						$pterms=get_terms('tribe_events_cat',$ptermargs);
    						$pterm_id=$pterms[0]->term_id;
    
    						$posttax=get_the_terms( $post_id, 'tribe_events_cat' );
    
    						foreach($posttax as $pt){
    							if($pt->parent == $pterm_id){
    								$state=$pt->name;															
    							}
    						}
    						$venue=tribe_get_venue();
    						if(trim($venue)!='' && !empty($venue)){
    							echo $venue."<br />";
    						}
    						$address=tribe_get_address();
    						if(trim($address)!='' && !empty($address)){
    							echo $address."<br />";
    						}
    
    						$city= tribe_get_city();
    						//$state= tribe_get_stateprovince();
    						$csp='';
    						if(trim($city)!='' && !empty($city)){
    							$csp.=$city;
    						}
    						if(trim($state)!='' && !empty($state)){
    							if($csp!='');
    							$csp.=", ".$state;
    						}else{
    							$csp.=$state;
    						}
    						echo $csp; 
    					?>
    				</p>
    
    			</div>
    			<?php 
    			// $catid = tribe_get_event_cat_ids();
    			// $catslug = tribe_get_event_cat_slugs($post_id);
    			$tax= array();
    			$terms = get_the_terms( $post->id, 'tribe_events_cat' );
    			if ($terms) {
    				foreach($terms as $t) {
    					array_push($tax, $t->slug);
    				}
    			}
    
    			//print_r($terms);
    
    			//Returns Array of Term Names for "my_term"
    			// $term_list = wp_get_post_terms($post->ID, 'tribe_events_cat', array("fields" => "slug"));
    			// print_r($term_list);
    
    			// $catslug = tribe_get_event_taxonomy();
    			// echo $catslug;
    			// echo $post_id;
    			// echo $catslug[$post_id];
    			// print_r($catslug);
    			// print_r($catid);
    
    			// echo 'Event link: '. tribe_event_link().'<br>';
    			// echo 'End Date: ' . tribe_get_end_date(). '<br>';
    
    			// echo 'address: '. tribe_get_address() . '<br>';
    			// echo 'City: ' . trit_city().be_ge '<br>';
    			// echo 'Cost: ' . tribe_get_cost(). '<br>';
    			// echo 'Country: ' . tribe_get_country(). '<br>';
    			// echo 'Google Map: ' . tribe_get_embedded_map(). '<br>';
    			// echo 'Map link: '. tribe_get_map_link().'<br>';
    
    			// // Organizer
    			// echo 'Organizer: ' . tribe_get_organizer().'<br>';
    			// echo 'Organizer Email: ' . tribe_get_organizer_email().'<br>';
    			// echo 'Organizer Link: ' . tribe_get_organizer_link().'<br>';
    			// echo 'Organizer phone: ' . tribe_get_organizer_phone().'<br>';
    			// echo 'Organizer website: ' . tribe_get_organizer_website_url().'<br>';
    			// echo 'Organizer link: ' . tribe_get_organizer_website_link().'<br>';
    
    			// Venue
    			?>
    
    			<?php do_action( 'tribe_events_single_event_after_the_meta' ) ?>
    			</div><!-- .hentry .vevent -->
    		<?php if( get_post_type() == TribeEvents::POSTTYPE && tribe_get_option( 'showComments', false ) ) comments_template() ?>
    	<?php endwhile; ?>
    	<!-- Event footer -->
    
        <div id="tribe-events-footer">
    		<!-- Navigation -->
    		<!-- Navigation -->
    		<h3 class="tribe-events-visuallyhidden"><?php _e( 'Event Navigation', 'tribe-events-calendar' ) ?></h3>
    		<ul class="tribe-events-sub-nav">
    			<li class="tribe-events-nav-previous"><?php tribe_the_prev_event_link( '<span>&laquo;</span> %title%' ) ?></li>
    			<li class="tribe-events-nav-next"><?php tribe_the_next_event_link( '%title% <span>&raquo;</span>' ) ?></li>
    		</ul><!-- .tribe-events-sub-nav -->
    	</div><!-- #tribe-events-footer -->
    
    <!-- Upcoming Events -->
    	<div class="upcoming-event-circle cf">
    			<div class="col-md-12">
    				<div class="title">
    					<h1><i class="event-icon icon-size27"></i>UPCOMING <?php echo tribe_get_event_taxonomyc(); ?> EVENTS</h1>
    				</div>
    			</div>
    			<div class="cf"></div>
    			<?php
    			global $post;
    			$all_events = tribe_get_events(
    				array(
    					'eventDisplay'=>'upcoming',
    					'posts_per_page'=>3,
    					'tax_query'=> array(
    						array(
    							'taxonomy' => 'tribe_events_cat',
    							'field' => 'slug',
    							'terms' => $tax
    						)
    					)
    			)
    			);
    
    			foreach($all_events as $post) {
    			setup_postdata($post);
    			?>
    
    			<div class="col-md-4 col-sm-4 col-xs-4 upcoming-events events-list circle-shape">
    				<a href="<?php the_permalink(); ?>">
    					<div class="img-con">
    						<?php 
    						$attachment_id  = get_the_id(); 
    						wp_get_attachment_image_src( $attachment_id );
    						if( $image_attributes ) { $w = $image_attributes[1]; $h = $image_attributes[2]; }
    						echo $h;
    						echo $w;
    						if ($h>$w) { 
    							the_post_thumbnail('circle-square', array('class' => 'wauto')); 
    						}elseif ($w>$h){
    							the_post_thumbnail('circle-square', array('class' => 'hauto')); 
    						}else {
    							the_post_thumbnail('circle-square'); 
    						}
    						?>
    					</div>
    					<div class="col-md-3 col-sm-4 event-date">
    						<div class="date">
    							<div class="month">
    								<?php echo tribe_get_start_date( $post->ID, false, 'M' ); ?>
    							</div>
    							<div class="day"><?php echo tribe_get_start_date( $post->ID, false, 'd' ); ?> </div>
    						</div>
    					</div>
    					<div class="col-md-9 col-sm-8 event-content">
    						<div class="event-details">
    							<div class="padded-textviolet-left padded-lborder-w20 padded-marginb18 text-uppercase">
    								<h3 class="padded-font18"><strong><?php the_title(); ?></strong></h3>
    							</div>
    							<p><strong><?php echo tribe_get_venue(); ?></strong></p>
    							<p><?php the_excerpt(); ?></p>
    						</div>
    					</div>
    				</a>
    			</div>
    
    	<?php } //endforeach ?>
    	<?php wp_reset_query(); ?>
    
    </div>
    </div>
    </div>
    <script>
    jQuery(document).ready( function($){
    	var c=$(".us_cpt_top").clone();
    	console.log("content -> "+c);
    	$(".us_cpt_top").remove();
    	$(".event-title").after(c);
    	$(".us_cpt_top").css("margin-top","20px");
    	$(".us_cpt_top .us_wrapper.tac").css("text-align", "left");
    });
    </script>
    

    Origianl Source

    <?php
    /**
     * Single Event Template
     * A single event. This displays the event title, description, meta, and
     * optionally, the Google map for the event.
     *
     * Override this template in your own theme by creating a file at [your-theme]/tribe-events/single-event.php
     *
     * @package TribeEventsCalendar
     *
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	die( '-1' );
    }
    
    $events_label_singular = tribe_get_event_label_singular();
    $events_label_plural = tribe_get_event_label_plural();
    
    $event_id = get_the_ID();
    
    ?>
    
    <div id="tribe-events-content" class="tribe-events-single vevent hentry">
    
    	<p class="tribe-events-back">
    		<a href="<?php echo esc_url( tribe_get_events_link() ); ?>"> <?php printf( __( '&laquo; All %s', 'the-events-calendar' ), $events_label_plural ); ?></a>
    	</p>
    
    	<!-- Notices -->
    	<?php tribe_events_the_notices() ?>
    
    	<?php the_title( '<h2 class="tribe-events-single-event-title summary entry-title">', '</h2>' ); ?>
    
    	<div class="tribe-events-schedule updated published tribe-clearfix">
    		<?php echo tribe_events_event_schedule_details( $event_id, '<h3>', '</h3>' ); ?>
    		<?php if ( tribe_get_cost() ) : ?>
    			<span class="tribe-events-divider">|</span>
    			<span class="tribe-events-cost"><?php echo tribe_get_cost( null, true ) ?></span>
    		<?php endif; ?>
    	</div>
    
    	<!-- Event header -->
    	<div id="tribe-events-header" <?php tribe_events_the_header_attributes() ?>>
    		<!-- Navigation -->
    		<h3 class="tribe-events-visuallyhidden"><?php printf( __( '%s Navigation', 'the-events-calendar' ), $events_label_singular ); ?></h3>
    		<ul class="tribe-events-sub-nav">
    			<li class="tribe-events-nav-previous"><?php tribe_the_prev_event_link( '<span>&laquo;</span> %title%' ) ?></li>
    			<li class="tribe-events-nav-next"><?php tribe_the_next_event_link( '%title% <span>&raquo;</span>' ) ?></li>
    		</ul>
    		<!-- .tribe-events-sub-nav -->
    	</div>
    	<!-- #tribe-events-header -->
    
    	<?php while ( have_posts() ) :  the_post(); ?>
    		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    			<!-- Event featured image, but exclude link -->
    			<?php echo tribe_event_featured_image( $event_id, 'full', false ); ?>
    
    			<!-- Event content -->
    			<?php do_action( 'tribe_events_single_event_before_the_content' ) ?>
    			<div class="tribe-events-single-event-description tribe-events-content entry-content description">
    				<?php the_content(); ?>
    			</div>
    			<!-- .tribe-events-single-event-description -->
    			<?php do_action( 'tribe_events_single_event_after_the_content' ) ?>
    
    			<!-- Event meta -->
    			<?php do_action( 'tribe_events_single_event_before_the_meta' ) ?>
    			<?php tribe_get_template_part( 'modules/meta' ); ?>
    			<?php do_action( 'tribe_events_single_event_after_the_meta' ) ?>
    		</div> <!-- #post-x -->
    		<?php if ( get_post_type() == Tribe__Events__Main::POSTTYPE && tribe_get_option( 'showComments', false ) ) comments_template() ?>
    	<?php endwhile; ?>
    
    	<!-- Event footer -->
    	<div id="tribe-events-footer">
    		<!-- Navigation -->
    		<h3 class="tribe-events-visuallyhidden"><?php printf( __( '%s Navigation', 'the-events-calendar' ), $events_label_singular ); ?></h3>
    		<ul class="tribe-events-sub-nav">
    			<li class="tribe-events-nav-previous"><?php tribe_the_prev_event_link( '<span>&laquo;</span> %title%' ) ?></li>
    			<li class="tribe-events-nav-next"><?php tribe_the_next_event_link( '%title% <span>&raquo;</span>' ) ?></li>
    		</ul>
    		<!-- .tribe-events-sub-nav -->
    	</div>
    	<!-- #tribe-events-footer -->
    
    </div><!-- #tribe-events-content -->
    
    • This reply was modified 10 years, 6 months ago by Mitch.
    #1010006
    Brian
    Member

    I glanced over the coding and see this is the map function:

    <?php echo tribe_get_embedded_map($post_id, 100, 800, false); ?>

    That should be correct as it is the function we use:

    plugins/the-events-calendar/src/views/modules/meta/map.php

    I think it is actually this foreach causing the issue:

    foreach($posttax as $pt){
    if($pt->parent == $pterm_id){
    $state=$pt->name;
    }
    }

    You might be able to do a check like this to make sure it is an array

    if ( is_array( $posttax ) ) {

    foreach($posttax as $pt){
    if($pt->parent == $pterm_id){
    $state=$pt->name;
    }
    }

    }

    Beyond that I am limited in troubleshooting custom coding, but can try to help out some more.

    Thanks

    #1014870
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Google map not displaying’ is closed to new replies.