Skip Navigation

[Resolved] Filter by distance consumes usage of geocoding Google API

This support ticket is created 2 years, 2 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.

Our next available supporter will start replying to tickets in about 0.53 hours from now. Thank you for your understanding.

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 3 replies, has 2 voices.

Last updated by Minesh 2 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#2466663

Hi, I've a CPT with a Maps Addres custom field. I built a view to display a list of entries filtered by distance from the current entry page address.

I need to know if the filter by distance consumes usage of geocoding Google API. Does it?

If yes, is it possible to reduce it by caching the view? The closest places are always the same, we won't update them often.

thanks
Cheers

#2467073

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

When filtering by distance users enter a location to search from in a text field, and we add those addresses to the address cache as well as those stored in custom field address fields.

But the auto-suggestion that is shown by address field does contact the Places API, even if the user ends up entering a place that has been searched for previously. I don't think that can be avoided.

Lets say, you want to use the current post address field so when you try to create a new post and add address field and save the post at that time Toolset will automatically cache the address string you added to address field of this newly submitted post.

Then if you want to filter the posts with current post address field and before query the map API it will check the maps cache table and if the address is available it wont query the map API.

Please check the following Doc:
- https://toolset.com/course-lesson/data-caching-for-maps-addresses/

#2467077

Hi, I explain a little more. I've the CPT Sights, each sight has a location address.

This view is displayed in the Content template for Single Sights, where I want to display the nearby sights in a radius of 10km ordered by distance.

I've added a Query filter (not a search filter, you can see it in the attached image) and I pass the current Single Sights latitude and longitude by the shortcode attribute:

[wpv-view name="sights-nearby-distance" mapcenter="[types field='location' format='FIELD_LATITUDE'][/types],[types field='location' format='FIELD_LONGITUDE'][/types]"]

Does this setup uses cached information without calling Google API?

I've also set the order by distance from a Fixed address. I'm getting the fixed address with this shortcode: [wpv-attribute name="mapcenter"] (see attached image).

Does this setup work?
It seems it works, but I'm not completely sure it gets correctly the fixed value by the attribute shortcode.

thanks
cheers

#2467139

Minesh
Supporter

Languages: English (English )

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

I've also set the order by distance from a Fixed address. I'm getting the fixed address with this shortcode: [wpv-attribute name="mapcenter"] (see attached image).
==>
You did not share the image but thats ok.

Regarding the address field, it only asks the Google API for the address coordinate address and it Caches the result, and uses the cache every time after that. If there is a address that is not cached then it will fire the Google API one, cache the results and then later when the same address is used, it will be used from cache as its available with map cache table.