Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #18111
    pbrumby
    Participant

    Hi,

    I want to be able to create a direct link to Google maps and streetmap.co.uk

    I can do this by using the lat and long values. What I’m struggling with is how do I echo the lat and long values.

    Thanks

    #18219
    pbrumby
    Participant

    I’ve figured it out with a bit of extra help. This is how you echo a link to Google maps and streetmaps using lat and long values.

    <?php 
    
    $locations = em_get_locations_for( $post->ID );
    
    if ( ! empty( $locations ) && is_array( $locations ) ) {
    		foreach ( $locations as $id => $location ) {
    			$optionValue = ( get_option( 'event_location_' . $location->term_taxonomy_id ) ? get_option( 'event_location_' . $location->term_taxonomy_id ) : get_option( 'event_location_' . $location->term_id ) );
    
    $pb_google_map_limk = "https://www.google.com/maps/?q=" . $optionValue["google_map"]["latitude"] . "," . $optionValue["google_map"]["longitude"];
    
    $pb_streetmap_limk = "http://streetmap.co.uk/loc/" . $optionValue["google_map"]["latitude"] . "+" . $optionValue["google_map"]["longitude"];
    
    		}
    		
    	}
    
    ?>
    
    <p><a href="<?php echo $pb_streetmap_limk ?>">View location on Streetmaps</a></p>
    <p><a href="<?php echo $pb_google_map_limk ?>">View location on Google</a></p>
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.