Show nearby places on map on details page

This topic contains 13 replies, has 4 voices, and was last updated by  Kiran 3 years, 12 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #542798

    andymodess
    Lifetime Member
    Post count: 7

    I try to show nearby places in a map on the detail page but only get the map to show places in the same city. I want the map to show nearby places even if it is in a nearby city or even in a nearby region.

    When I use the following shortcodes I get every place nearby in the list but the map shows only those in the same city.

    Is it a bug, am I doing it wrong or does it not work like that?

    Thanks!

    LIST:

    [gd_listings post_type="gd_place" post_limit="8" add_location_filter="0" sort_by="distance_asc" layout="0" view_all_link="1" bottom_pagination="1" hide_if_empty="1" category="0"]

    MAP:

    [gd_map width="100%" height="650px" maptype="ROADMAP" zoom="0" map_type="directory" post_settings="1" add_location_filter="0" tags=".geodir-listings"]
    #542804

    Kor
    Moderator
    Post count: 16516

    Hi andymodess,

    Thanks for your post. Try enabling the “Location Filter” as explained here https://wpgeodirectory.com/docs-v2/design/gd-listings/#options and see if it works for you.

    #542805

    andymodess
    Lifetime Member
    Post count: 7

    Hi Kor,

    No, if I’m enabling the Location Filter I get No Records Found in both list and map.

    I think it’s because of the same issue. There is only one place in that city. But there is a place in a city nearby that I want to show in the map. It works on list but not on map.

    #542814

    Kor
    Moderator
    Post count: 16516

    Hi andymodess,

    Thanks for your reply. Could you try using the shortcode below and see if it works for you.

    [gd_map width="100%" height="425px" maptype="ROADMAP" zoom="0" map_type="directory" post_settings="1" post_type="gd_place" search_filter="1" post_type_filter="1" cat_filter="1"]
    #542838

    andymodess
    Lifetime Member
    Post count: 7

    That code just gave me the place i’m visiting for the moment (one place). The list showing 8 places. Sorry that didn’t work.

    The shortcode i used in my question gave me 4 places. All in the same city.

    #542857

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    Are you trying to show 2 maps? The Post Map (with the map location for listing) along with a directory map of nearby listings?

    Please share WP Admin credentials and a link to where we can see what you have done so far.

    #543006

    andymodess
    Lifetime Member
    Post count: 7
    This reply has been marked as private.
    #543184

    Kiran
    Moderator
    Post count: 7069

    Hello,

    Try following PHP snippet to disable city filter on detail page maps.

    
    
    /**
     * Disable city filter on detail page on custom loop map.
     */
    function gd_snippet_200429_map_params( $params, $map_args ) {
    	if ( ! empty( $params['tags'] ) && ( strpos( $params['tags'], '.' ) === 0 || strpos( $params['tags'], '#' ) === 0 ) ) {
    		$params['country']       = '';
    		$params['region']        = '';
    		$params['city']          = '';
    		$params['neighbourhood'] = '';
    	}
    
    	return $params;
    }
    add_filter( 'geodir_map_params', 'gd_snippet_200429_map_params', 20, 2 );

    Regards,
    Kiran

    #543190

    andymodess
    Lifetime Member
    Post count: 7

    Hi Kiran,
    With that function I get the same result cause the if doesn’t fire. But if I set the $params outside the if, all my places shows up in the map.

    That could be a solution if I can limit the places and sort it by distance. Is that possible?

    #543197

    Kiran
    Moderator
    Post count: 7069

    Provide us FTP credentials and also tell where you put that snippet.

    Kiran

    #543198

    andymodess
    Lifetime Member
    Post count: 7
    This reply has been marked as private.
    #543201

    Kiran
    Moderator
    Post count: 7069

    Hello,

    I have added new parameter

    tags="#gd_list_test .geodir-listings"

    in gd_map shortcode on detail page template.

    Please check and let us know.

    Kiran

    #543206

    andymodess
    Lifetime Member
    Post count: 7

    Yes, it was exactly so I wanted it. So it was the id that was also needed to make it work?

    Big thanks for the help!

    #543207

    Kiran
    Moderator
    Post count: 7069

    Yes, to show listings from custom loop you need to set div id or class of the gd_listings container to tags attribute. So it shows posts within from gd_listings loop.

    Kiran

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

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

Open Support Ticket