Show nearby places on map on details page
This topic contains 13 replies, has 4 voices, and was last updated by Kiran 5 years, 6 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
April 27, 2020 at 11:47 am #542798
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"]April 27, 2020 at 12:20 pm #542804Hi 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.
April 27, 2020 at 12:34 pm #542805Hi 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.
April 27, 2020 at 1:08 pm #542814Hi 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"]April 27, 2020 at 2:50 pm #542838That 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.
April 27, 2020 at 3:49 pm #542857Hello,
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.
April 28, 2020 at 5:52 am #543006This reply has been marked as private.April 29, 2020 at 5:55 am #543184Hello,
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,
KiranApril 29, 2020 at 6:53 am #543190Hi 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?
April 29, 2020 at 7:40 am #543197Provide us FTP credentials and also tell where you put that snippet.
Kiran
April 29, 2020 at 7:57 am #543198This reply has been marked as private.April 29, 2020 at 8:33 am #543201Hello,
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
April 29, 2020 at 9:55 am #543206Yes, 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!
April 29, 2020 at 9:59 am #543207Yes, 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
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket