Tribe__Events__Main::googleMapLink( int|null $post_id = null )

Returns a link to google maps for the given event. This link can be filtered using the tribe_events_google_map_link hook.


Parameters

$post_id

(int|null) (Optional)

Default value: null


Top ↑

Return

(string) a fully qualified link to <a href="https://maps.google.com/">https://maps.google.com/</a> for this event


Top ↑

Source

File: src/Tribe/Main.php

		public function googleMapLink( $post_id = null ) {
			if ( $post_id === null || ! is_numeric( $post_id ) ) {
				global $post;
				$post_id = $post->ID;
			}

			$locationMetaSuffixes = array( 'address', 'city', 'region', 'zip', 'country' );
			$to_encode = '';
			$url = '';

			foreach ( $locationMetaSuffixes as $val ) {
				$metaVal = call_user_func( 'tribe_get_' . $val, $post_id );
				if ( $metaVal ) {
					$to_encode .= $metaVal . ' ';
				}
			}

			if ( $to_encode ) {
				$url = 'https://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=' . urlencode( trim( $to_encode ) );
			}

			return apply_filters( 'tribe_events_google_map_link', $url, $post_id );
		}