Support Forum
Support › MB Settings Page › Google Maps using default API key MB Settings Page with Meta Box GroupsResolved
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.
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
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.
The other thing to note when I output the map not using a Meta Box Group our map API key is output correctly.
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.
Perfect, that solved it. thanks again for your help, much appreciated.
That solved my issue after creating multiple billing accounts and it took me few days to end up in this post , this should be included in Plugins main info in RED marking lol.