Support

Account

Home Forums Front-end Issues Google map initial value using load_value()

Helping

Google map initial value using load_value()

  • Hello,

    (besides others πŸ™‚ I am facing the following issue. A google map is retrofitted in a form, so I want users to verify their addresses on the google map, so I would like the google map to be loaded the first time using the fields users have already filled – address, zip code and city, but can’t make it work – not even sure if it’s possible.

    I am using it inside an acf_form in the front-end, no additional code than the form itself.

    I tried the following:

    function google_map_value( $value ) {
    	if (!$value) {
    		$user_address = get_user_meta(get_current_user_id(), 'user_address', true);
    		$user_city = get_user_meta(get_current_user_id(), 'user_city', true);
    		$user_address_code = get_user_meta(get_current_user_id(), 'user_address_code', true);
    		$value['address'] = $user_address.' '.$user_city.' '.$user_address_code;
    	}
      return $value;
    }
    add_filter('acf/load_value/name=user_google_map', 'google_map_value');

    The map now load showing the address I want in the google map info field but doesn’t trigger. What am I missing?

    I also tried using JS, but couldn’t pinpoint the event of the map loading to properly compose the address to the google map field.

    Edit: Also, how can you trigger the search programmatically? I read a few threads here, but nothing seems to be working (eg by triggering enter on the input)

  • This helped me immensely , keep it up. God bless you.

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

You must be logged in to reply to this topic.