Skip Navigation

[Resolved] Issues displaying large number of posts on map

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 10 replies, has 3 voices.

Last updated by Minesh 6 years ago.

Assisted by: Minesh.

Author
Posts
#1134674
2018-10-26 14_24_20-Stockists - Flexo.png

I've run into an issue. I'm building a store-finder view (you'll find it on the /stockists/ page. I'll provide access to the site below). Currently, we have 300+ stockists (though this is definitely growing).

Problem is, if I try to display all the stockists on the map at the same time, the page times out and I end up with a 500 server error.

So, I've enabled pagination to display 10 of the stockists at a time (see screenshot) just to test it out, which works fine in theory- but as you'll see, it grabs them via some strange order which means I see stockists around the world- not just the ten nearest me. I read in the Maps 1.5 docs that "When displaying a list of content, including posts, users, and taxonomy terms, you can now order them by distance from a specific location or the current user’s geolocation." Is that not applicable to the Map? Only list views?

Is there perhaps a way to not load the map until a user enters their address, and either a) display all stockists within 100km of them or b) load the nearest 10 stockists?

Or perhaps another method I may not have considered?

I'll provide a login so you can see how it's set up etc. The view is called " View Stockists - Map"

#1135002

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - could you please share problem URL where you added your map with view?

Basically - if already setup distance filter with your view.
=> https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/#filtering-markers-by-distance

Then, to not to load any results until you search, you need to add following code to your current theme's functions.php file:

add_filter( 'wpv_filter_query', 'func_load_no_results', 101, 3 );
function func_load_no_results( $query_args, $view_settings, $view_id ){
 
  $affected_views = array( 999 ); // Add IDs of relevant Views
 
  if ( in_array( $view_id, $affected_views ) && !isset( $_REQUEST['toolset_maps_distance_radius'] ) ) {
    $query_args['post__in'] = array( 0 );
  }
   
  return $query_args;
}
#1135411

The URL is /stockists/

I've added the code to my functions.php & set the view ID to 1281, but it doesn't appear to actually do anything?

#1136035

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I see there is "No Items found" message that means the code is working, means when you load view by default it will not list any items. So now if you search, do it load the map and items with markers?

#1136227
2018-10-30 09_17_35-.png

Nope. It doesn't. Take my city for example (Wellington, New Zealand.) There is a Toyworld here, but if I enter my address, nothing is loaded on the map. See screenshot.

#1136566

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I dont know why but I just added a submit button to view's filter and then I try to add the address and click on submit button to filter the view results but it gives me "Gateway Timeout" error or "Internal Server Error".

<em><u>hidden link</u></em>

Could you please check with your server authority why its throwing such errors.

#1136571

Minesh, it times out/throws that error because toolset doesn't seem to like loading 350+ posts- which is the core of this issue. See in my OP "Problem is, if I try to display all the stockists on the map at the same time, the page times out and I end up with a 500 server error."

#1136578

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Actually - we already added the pagination to view, so that should not be the issue as we are loading 10 items per page.

I changed the theme to default 2017 and I see some improvement that map is loaded with the markers instead of blank map.

To debug this issue further, I need duplicator copy of your site so that I can install it on my local test server and start debugging it to locate the issue.

Could you please send me duplicator copy of your site:
=> https://toolset.com/faq/provide-supporters-copy-site/

I have set the next reply to private which means only you and I have access to it.

#1137028
#1137512

Hi,

Minesh has one day vacation, you will get the response ASAP when he back on Thursday.

#1138166

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - Thank you for sharing the duplicator package. I'm downloading it. I will feedback you here as soon as I find anything.

#1138936

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I tried a couple of times but I could not able to install it as I get database error while installing the duplicator.

Could you please send me duplicator file with minimum installation where just deactivate the unwanted plugins.

I have set the next reply to private which means only you and I have access to it.