Custom Fields
Re-Envisioned
Support MB Settings Page Google Maps using default API key MB Settings Page with Meta Box Groups

  • Creator
    Topic
  • #20917
    Resolved ambrdigital
    Participant

    We are using the MB Settings Page to display our company’s contact details, we have multiple locations so we are using the Meta Box Groups extension as well.

    The issue we are having is with the Maps field is not using our API key on the frontend, and it is defaulting to the Meta Box generic API key. however, in the WordPress backend, our API key is being used correctly.

    We are using the RWMB_Map_Field::render_map() function because it is in a group and everting is outputting correctly. The only issue is the API key set in the Map field is not being used on the front end when registering the maps.google script.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #20925
    Long Nguyen
    Moderator

    Hi,

    That means you are using a script code on the front end and it has another Google API key? The field Google Map only takes the API key in the field settings base on our design. You can add more libraries via filter rwmb_google_maps_url. See more in the documentation
    https://docs.metabox.io/fields/map/#filters
    https://developers.google.com/maps/documentation/javascript/libraries

    #20928
    ambrdigital
    Participant

    Thanks for the replay, I am confident that its a meta box issue because the API Key being outputted is the default that can be found in the meta box plugin. Note we are using the Meta Box AIO version.

    meta-box/inc/fields/map.php
    ‘api_key’ => ‘AIzaSyC1mUh87SGFyf133tpZQJa-s96p0tgnraQ’, on line 108 and again 182.

    Again I have an active API key in my code everything is working as desired except the API key.

    #20929
    ambrdigital
    Participant

    The other thing to note when I output the map not using a Meta Box Group our map API key is output correctly.

    #20931
    Long Nguyen
    Moderator

    Hi,

    You can use the second parameter $args to pass the API key to the map.

    $group_values = rwmb_meta( 'group_id' );
    $args = array(
        'api_key' => 'your-API-key'
    );
    // If group is cloneable
    foreach ( $group_values as $group_value ) {
        echo RWMB_Map_Field::render_map( $group_value['map_id'], $args );
    }

    Let me know how it goes.

    #20942
    ambrdigital
    Participant

    Perfect, that solved it. thanks again for your help, much appreciated.

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