Support

Account

Home Forums Front-end Issues Updating google map field using update_field

Solved

Updating google map field using update_field

  • Hi there

    I am trying to add values to an ACF field from a front end form. I can update most of my fields fine but am getting a little bit stuck when trying to use update_field to update a location map field.

    I have used the google maps geocoding api to convert an address value into latlon co-ords and am then trying to use update_field to insert an array containing data in the following format into the field. When I check in the back end to see if it has worked it just says ‘Array’ next to the ‘find the complete address’ icon.

    The data I am attempting to insert is in the following format:

    $location = array(
    ‘address’ => ‘merseyside,l3 9pp’,
    ‘lat’ => ‘53.3815883’,
    ‘lng’ => ‘-3.0302063’
    );

    .. and these are the function calls I am using:

    update_field(‘event_date’, $event_date, $post_id);
    update_field(‘event_start_date’, $event_start_date, $post_id);
    update_field(‘event_location’, $location, $post_id);

    The first 2 insert fine.

    Could you possibly point me in the right direction

  • Hmm, maybe I should check properly first. Turns out there was a different plugin extension being used on this project which added a field type called ‘location map’ to ACF and this stores the data in a completely different format.

    Checked in the db to see how it was stored and it was simply address and latlon separated with a bar character.

    Apologies if I wasted anyone’s time with this question.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Updating google map field using update_field’ is closed to new replies.