How to output ACF lat long from map with PHP function

Hey! I have an ACF map and can output the lat/long with the following code:

<?php echo get_field('listing_location')['lat']; ?>
<?php echo get_field('listing_location')['lng']; ?>

How do I translate that into Bricks dynamic “Output PHP function”?

I’ve tried the following, which doesn’t work:

{echo:get_field('listing_location')['lat']}

I need this output to render a marker on my Bricks map element.

Thanks!

Writing a seperate function for it works, but I was curious if there’s a way without doing that.

function get_listing_location_lat() {
    $listing_location = get_field('listing_location');
    if ($listing_location && isset($listing_location['lat'])) {
        return $listing_location['lat'];
    } else {
        return null; // or you can return a default value if needed
    }
}

{echo:get_listing_location_lat()}

Hi @johannes

If you are using 1.8beta-2, you can use :array_value filter

Example:
{acf_place_map:array_value|lat}
{acf_place_map:array_value|lng}

Regards,
Jenn

Hi @itchycode

This is pretty cool, I’ll give it a try.

Thanks a lot!