Skip Navigation

[Resolved] Maps reading back marker latlon

This support ticket is created 4 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
- 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/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 4 years ago.

Assisted by: Waqar.

Author
Posts
#1903245
Toolset.png

I am trying to access the lat and log that google maps encodes from a full address.
I expected to find in the the user-address field (which is an address type)
See this code
------------
$start_post_ID = $_SESSION["startpostid"]; //first pilot post ID
$start_latlon = explode(",", get_post_meta($start_post_ID, 'wpcf-user-address', true));
$this_latlon = explode(",", get_post_meta($post_ID, 'wpcf-user-address', true));
$a = intval(distance($start_latlon[0], $start_latlon[1], $this_latlon[0], $this_latlon[1], "M"));
update_post_meta( $post_ID, 'wpcf-range', $a );
--------------
Can you please advise what is the proper parameter name to use and how to access it here
See the image, that the address has been properly encoded into lat and lon

#1903407

Hi,

Thank you for contacting us and I'd be happy to assist.

Toolset Maps stores the selected human-readable address and not the lat and lon coordinates as the raw custom field values in the address type fields. For this reason, "get_post_meta" function won't help in this case.

To get the lat and lon coordinates from the address type custom field, you can use the "types_render_field" function from Types Fields API.
( ref: https://toolset.com/documentation/customizing-sites-using-php/functions/#address )

Example:


// get lat from a custom field "user-address" from post with ID 1
$user_lat = types_render_field('user-address', array('item' => '1', 'format' => 'FIELD_LATITUDE'));

// get lon from a custom field "user-address" from post with ID 1
$user_lat = types_render_field('user-address', array('item' => '1', 'format' => 'FIELD_LONGITUDE'));

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar