Hi Eric,
Thank you for waiting.
As discusses earlier, the "toolset-maps-distance-value" shortcode ( ref: https://toolset.com/documentation/user-guides/maps-shortcodes/#toolset-maps-distance-value ), expects the "location" attribute value to be either an address or latitude/longitude pair.
This means that passing on a location field's slug won't work, but we can use that field's value in the shortcode, indirectly, through Toolset Types Fields API:
( ref: https://toolset.com/documentation/customizing-sites-using-php/functions/#address )
<code
[toolset-maps-distance-value location='[types field="travel-destination-coordinates"][/types]' postmeta='wpcf-map-coordinates']
[/php]
If you're already using the latitude and longitude values in the "wpcf-map-coordinates" field, they must be stored separated by a comma.
You can extract the latitude and longitude separately using a custom shortcode like this:
add_shortcode( 'get_lat_lon_value', 'get_lat_lon_value_func');
function get_lat_lon_value_func( $atts ) {
$atts = shortcode_atts( array(
'value' => '',
), $atts );
$field_value = types_render_field("map-coordinates", array());
if(!empty($field_value)) {
$field_value_arr = explode(",", $field_value);
if ($atts['value'] == 'lat') {
return trim($field_value_arr[0]);
}
elseif ($atts['value'] == 'lon') {
return trim($field_value_arr[1]);
}
}
}
You can add this in your active theme's "functions.php" file and then add "get_lat_lon_value" in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content.
To get the latitude and longitude values, you can use the shortcode as:
latitude:
[get_lat_lon_value value="lat"]
longitude:
[get_lat_lon_value value="lon"]
This way you can use these values in your map's shortcode "wpv-map-render".
( ref: https://toolset.com/documentation/user-guides/maps-shortcodes/#wpv-map-render )
Example:
[wpv-map-render map_id="map-ID" fitbounds="off" general_center_lat="[get_lat_lon_value value='lat']" general_center_lon="[get_lat_lon_value value='lon']" general_zoom="5"][/wpv-map-render]
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar