Show button "Open in Google Maps"

This topic contains 5 replies, has 4 voices, and was last updated by  msattolo 8 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #35526

    paralosreg
    Free User
    Post count: 15

    Hello.
    I’d like show a button to open the location in a google maps new window (or GMaps app in mobile). Are there any built option with this action? Thx

    #35550

    Simone
    Expired Member
    Post count: 3515

    Hello, this is not possible,e but I made a function

    copy the attached code in the functions.php file inside your child theme’s folder

    It will appear in the sidebar, right below the social sharing button (top right)

    #35568

    paralosreg
    Free User
    Post count: 15

    Great!!!

    I change a little, following this:

    Here’s the info on Google’s URL:

    http://maps.google.com/maps?z=12&t=m&q=loc:38.9419+-78.3020

    z is the zoom level (1-20)
    t is the map type (“m” map, “k” satellite, “h” hybrid, “p” terrain, “e” GoogleEarth)
    q is the search query, if it is prefixed by loc: then google assumes it is a lat lon separated by a +

    And this is my code to help who need it

    
    
    <?php
    
    add_action('geodir_after_social_sharing_buttons' , 'buttonmap', 10);
    function buttonmap(){
    global $post, $wp_query, $preview, $geodirectory;
    $postid = $wp_query->post->ID;
    $address= geodir_get_post_meta($postid,'post_address',true); //address
    $e_add = str_replace(' ', '+', $address); // + in space eg road+street+23
    
    $lat= geodir_get_post_meta($postid,'post_latitude',true); //lat
    $lon= geodir_get_post_meta($postid,'post_longitude',true); //lon
    //echo $e_add.$lat.$lon;
    
    echo "<a href="http://maps.google.com/maps?z=12&t=m&q=loc:".$lat."+".$lon."" target="_blank"> Mostra en Google Maps</a>";
    } 
    
    
    #35570

    Simone
    Expired Member
    Post count: 3515

    Glad to know you’re capable of tweaking it 🙂

    #37377

    MC1171611
    Full Member
    Post count: 180

    This is basically what I was asking for in this thread: https://wpgeodirectory.com/support/topic/simpler-directions-for-mobile

    Thank you for providing this code.

    #49337

    msattolo
    Free User
    Post count: 42

    Hi, will this code load me another page with google maps or would it take me to the google map app, when I am in mobile?
    Thank you
    Miriam

Viewing 6 posts - 1 through 6 (of 6 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket