Skip Navigation

[Resolved] Storing latitude and longitude coordinates in an array

This support ticket is created 2 years, 5 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 1 reply, has 2 voices.

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

Assisted by: Luo Yang.

Author
Posts
#2372881

Ian

We are planning on some updates to the website with more of a focus on location.

We are planning on using the WP Gridbuilder Plugin. (I recently used this plugin for another site using Toolset, not using maps, and was blown away by the speed increase due to its caching setup.

We need to store location information as latitude and longitude for two reasons; 1.) In order to use this plugin, 2.) This is a rural region and many of the locations can not be placed on a map with an address.

I need some help storing a custom field in a format readable by the plugin. (The Map facet works with latitude and longitude coordinates. The source type should be a custom field with as value an array containing the coordinates like this:
[ 'lat' => 5.1025, 'lng' => 40.5548 ]) Here is a link to the plugin details hidden link and here is a link to a demo hidden link

If you could please give me some help storing the data in the proper format, I should be able to take things from there.

#2373873

Hello,

There isn't such kind of built-in feature within Toolset plugins, you might consider custom codes.

For example:
1) Setup two custom fields:
- Custom address field "my-address-field"
- Custom single line field "another-address- field"
2) after user set the custom address field "my-address-field" value, and save the post, use WordPress Action hook "save_post" to trigger a custom PHP function:
https://developer.wordpress.org/reference/hooks/save_post/
3) In this PHP function, get the "my-address-field" field latitude and longitude values:
https://toolset.com/documentation/customizing-sites-using-php/functions/#address
format those value as what you want, and save it into field "another-address- field"