• Resolved jsosa

    (@jsosa)


    I would like to create a full page map using Google Map API to display all of my listings in one map. All I need is access to each listing’s data, in particular, Latitude and Longitude. I know how to loop through an create an array with all the keys of ‘at_biz_dir’ post types. There is where I get stuck. I haven’t been able to figure out the code so that I can call the post using the post id and get the manual_lat and manual_lng you use on the ‘single_at_biz_dir.php’ template. Where is that variable coming from? How do you access the lat and long data for each post?

Viewing 1 replies (of 1 total)
  • Thank you very much for using the directorist.
    Now regarding the lat and long of every listing,
    Lat and long data are saved in an array along with some others data as post metadata with the ‘_listing_info’ meta key. The array is saved after serializing and encoding it using base64. See the following file to see how the _listing_info data is saved as metadata.

    file: directorist/includes/classes/class-metabox.php at the lines 103 & 119.

    In order to get the lat and long info of each listing, you need to fetch all listing then call the following helper method to get all information in an array which was stored using _listing_info meta key. Once you get the array, then you can easily get the lat and long information.

    Here is an example which you can use inside any listing loop.

    $listing_info = ATBDP()->metabox->get_listing_info($post->ID); // get listing information post meta in an array using the helper
    
    //(Optional but useful for understanding) now you can var_dump the $listing_info to see what data you got
    
    // now let's fetch lat and long
    $manual_lat = $listing_info['manual_lat'];
    $manual_long = $listing_info['manual_lng'];
    

    We think now you have an easy access to each listings lat and long using 3 lines of code in the loop.

    Feel free to ask us if you have any more query. You can also contact us at contact@aazztech.com for any kind of support faster.

Viewing 1 replies (of 1 total)
  • The topic ‘Access location information for each listing’ is closed to new replies.