Skip Navigation

[Resolved] Toolset Maps using a huge amount of virtual memory

This support ticket is created 2 years, 7 months 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 19 replies, has 2 voices.

Last updated by Luo Yang 2 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#2414513

I have now removed all bad location entries.

Two questions:

1) Is it possible for the "location" address field to only accept address values and nothing else so that nothing else other than a google address location is accepted and not things like email addresses?

2) The map is still slow to load. What needs to happen so the map can load fast.

#2415197

For the new questions:
1) Is it possible for the "location" address field to only accept address values and nothing else so that nothing else other than a google address location is accepted and not things like email addresses
If you are using Toolset Forms plugin for user to submit the address locations, you can use "cred_form_validate" filter hook to validate user's input, see our document:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate
For example:

add_filter('cred_form_validate','my_validation',10,2);
function my_validation($error_fields, $form_data)
{
    //field data are field values and errors
    list($fields,$errors)=$error_fields;
    //uncomment this if you want to print the field values
    //print_r($fields);
    //validate if specific form
    if ($form_data['id']== 123456 ) // replace 123456 with your post form ID
    {
        //check my_field value
		if(empty($_POST['toolset-extended-form-wpcf-address']['latitude']) || empty($_POST['toolset-extended-form-wpcf-address']['latitude'])){
			$errors['address']='Wrong Address Value!';
		}
    }
    //return result
    return array($fields,$errors);
}

Please replace 123456 with your post form ID

2) The map is still slow to load. What needs to happen so the map can load fast.
Since you are querying thousands posts in one post view, it will conduct performance problems, and will consume a lots of PHP memory.

In your case, you can consider these:
1) Increase your webserver PHP memory limitation
2) Add pagination into the post view

#2415495

1) I don't know where top put that code you sent. Where does it go?

2) I have increased the memory limit to 1GB but this is a server security risk. The page will use a lot of memory and will take a huge amount of time to load. If 10 users open it at the same time then 10GB of memory will be used and the server will most likely crash.

This needs to be fixed so it does not use so much memory.

How would pagination work? How to make this possible?

#2415925

q1) You can follow our document to put the custom codes here: Toolset-> Settings-> Custom code
https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

q2) You edit the post view "Profile Map":
1) in section "Pagination and Sliders Settings" enable the pagination settings.
2) in section "Search and Pagination", add the pagination links

#2417727

Two questions:

1) I added your custom code snippet into Toolset-> Settings-> Custom code and replaced the ID 123456 with my form post ID but it looks like the map location field is not validating and it's allowing me to enter anything else into the location field such as an email address.

2) I enabled pagination and it's a bit helpful. I want the map to automatically default to a specific location such as "Ontario, California" and I want it to show a default of listings within 20 mile radius of that location. Can you please provide me snippet and instructions on how to do it?

This is the code I have right now for my map,

[wpv-filter-start hide="false"]
[wpv-filter-controls]
<!-- Start of pagination -->
<div class="form-inline">
<div class="form-group">
<label for="wpv-pager-nav-dropdown">[wpml-string context="wpv-views"]Go to page[/wpml-string]</label>
[wpv-pager-nav-dropdown output="bootstrap"]
</div>
</div>
<!-- End of pagination -->
<div class="row search-filters">
<div class="col-sm-12">
<div class="form-grouphorizontal">
[wpv-control-distance default_distance="10" default_unit="mi" distance_center_required="yes" compare_field="address" distance_center_url_param="maps_distance_center" distance_radius_url_param="maps_distance_radius" distance_unit_url_param="maps_distance_unit" inputs_placeholder="<span>Results within </span>%%DISTANCE%% of %%CENTER%%"]
<div class=" buttons">
[wpv-filter-submit type="button" output="bootstrap"][wpv-filter-reset type="button" output="bootstrap"]
</div>
</div>
</div>
</div>
<div class="row filters-submit">
</div>
[/wpv-filter-controls]
[wpv-filter-end]

New threads created by Luo Yang and linked to this one are listed below:

https://toolset.com/forums/topic/i-want-the-map-to-automatically-default-to-a-specific-location/

#2419617
wrong-address.jpg

Q1) I assume we are talking about the post form "Edit profile" in your website, I have tried it in your website
hidden link
Clear the field "LOCATION" or fill a wrong value into it,
after submit the post form, I can see the error message:

The post was not saved because of the following problem:
Location: Wrong Address Value!

See my screenshot wrong-address.jpg

Q2) According to our support policy, we prefer one ticket one question, for other new questions, please check the new thread here:
https://toolset.com/forums/topic/i-want-the-map-to-automatically-default-to-a-specific-location/