Skip Navigation

[Resolved] Geographical Math Distance or Google Map Api ?

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 5 replies, has 2 voices.

Last updated by Nigel 5 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#1300413

Hi, i build myself a plugin, fully integrated witch toolset to calculate the math distance beetween locations, it also orders it by distance.

In these months i think you made the same, i choosed to use this formula because i would not to use Google Maps Api because slow and costs of the API.

My plugin stores lat & long in some custom fields and calculate the distance.

I read a post by toolset that now the views plugin made the order by distance via database caching the coordinates. I would like to start using views plugin order by distance because of pagination issues but i'm not totally sure about if doesn't use Google Api to calculate distances.

Could you tell me ?

In case your plugin uses Google Api i'd prefer to use mine, in this case is there any way to use my own formula integrating in views dashboard?

Thank You

#1300547

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

There is no provision in Toolset Maps for using any other source for location data than Google or Microsoft at the moment.

I can't recommend any solution because what you are suggesting simply isn't supported.

I just tried a couple of things to see if you might be able to customise it by reproducing how the data is stored in the database (a combination of wp_postmeta and a custom table wp_toolset_maps_address_cache) and removing the Google API key so that the site cannot communicate with Google (which it would do to show a map of the address field when editing posts, for example), but the problem is that this disables parts of the UI relating to Maps which you still need (such as the ability to insert a distance filter in a View, for example).

You can study how the data is stored in the database, but I'm not sure that it will be possible to proceed very far, and as I stated above something like this is not supported, I'm afraid.

#1300589

Sorry but i didn't ask this.
Please ready my question better

#1300677

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Re-reading your question I still cannot tell exactly what you want to do, and I developed my own custom geo-location solution for distance searching in WordPress long before Toolset added the functionality, so I'm familiar with what's involved.

The Toolset Maps plugin doesn't use the Google API to calculate distances, the distances are calculated with custom SQL queries. The Google API is used for converting addresses to coordinates and for displaying maps (including the small maps shown when editing posts), and this data is stored in post meta and a custom caching table.

Perhaps in theory you could populate the database with such data yourself, rather than using the Google Maps API, but you cannot create a View with distance search without the Toolset Maps plugin and a functioning API key.

It sounds like you want to make a View with distance searches but using your data instead of using the Google API, but that's not possible.

The new version of Maps with the custom caching table customises the SQL query generated by Views to add a JOIN to the caching table to include a distance calculation in the underlying query.

You could try a solution involving Views but not the Toolset Maps plugin where you run two separate queries. The first is your custom distance query, which returns an array of posts that meet some distance requirement, and you then use the wpv_filter_query API hook to modify the Views query and pass this array of post IDs and a post__in argument to limit the View results to those that match your distance requirement.

But this is an inefficient method that doesn't scale (it's what Toolset Maps used to do).

You may find it easier to add your own pagination solution to your existing method.

#1300687

Hi Nigel. I only would know if It used gmap api in distance calcuation, not about storing coordinates the First Time.
It Is a good news It does not require Maps for distance calculation. It was what i would like ti know.
Thank You

#1300703

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

OK, I'm glad I answered your question eventually even if I wasn't sure exactly what it was.

You need any more details, or we can close?