How to auto-populate a text field with postal_code from Google Maps Autocomplete

Support MB Geolocation How to auto-populate a text field with postal_code from Google Maps Autocomplete

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #49888
    Jayron CastroJayron Castro
    Participant

    Hello Meta Box Support Team,

    I am looking for the correct technical approach to auto-populate a specific text field with the postal_code component returned by the Google Maps Autocomplete.

    My Environment & Current Setup:

    • WordPress version: 6.9.4
    • Meta Box AIO: Version 3.6.1 (with MB Geolocation active).
    • Google Maps API Key is properly configured and restricted. The map renders perfectly.
    • Map Field: I have a Google Maps field (ID: h3_lead_mapa).
    • Address Field: I have a text field (ID: h3_lead_endereco) mapped inside the map's "Address field" setting. This works flawlessly: when I search for an address, it populates this text field.

    The Goal:
    I have a separate text field specifically for the Postal Code (ID: h3_lead_cep). I need this field to automatically receive the postal_code data as soon as the map resolves the address.

    Could you provide the exact syntax or custom setting required to bind the postal_code to my h3_lead_cep field? I am attaching a screenshot of the CPT UI for your reference.

    Image-1
    Image-2

    Thank you,
    Jayron Castro

    #49889
    PeterPeter
    Moderator

    Hello Jayron,

    Thanks for reaching out.

    If you have a different field ID from the address component ID postal_code. You can use the custom binding, following the documentation https://docs.metabox.io/extensions/meta-box-geolocation/#custom-binding

    and screenshots https://imgur.com/a/tRVPozs

    #49890
    Jayron CastroJayron Castro
    Participant

    Hello Peter,

    I have followed the exact procedure you recommended in your last interaction, using the custom binding method as shown in your screenshots, but it did not work.

    I added the "binding" key with the "postal_code" value to the Custom Settings of my "h3_lead_cep" field. No other changes were made.

    The result is that the field remains empty when an address is selected on the map. I have already cleared the cache and confirmed there are no JavaScript errors in the browser console. The synchronization simply does not happen in my environment (Meta Box AIO 3.6.1).

    I am attaching a video and screenshots showing my current configuration and the failure in real-time. Please analyze these materials and provide a solution for this.

    Video

    Images:

    1. Image-1
    2. Image-2
    3. Image-3
    4. Image-4
    #49892
    PeterPeter
    Moderator

    Hello,

    I'm not able to reproduce the same issue on my site. Please share your site admin account by submitting this contact form https://metabox.io/contact/
    I will take a look.

    #49894
    Jayron CastroJayron Castro
    Participant

    I submitted the data via the form.

    #49895
    PeterPeter
    Moderator

    Hello,

    I got the issue. You need to add geo.api_key to the field group settings and set the address field ID to start with address_. Please check this screenshot https://imgur.com/a/MIk8SMy
    and follow the documentation https://docs.metabox.io/extensions/meta-box-geolocation/#geolocation-api

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.