Google Maps not reading API key from MB Builder

Support MB Builder Google Maps not reading API key from MB Builder

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #30468
    ViktorViktor
    Participant

    I am creating a group of custom fields containing a Google Maps field using Meta Box AIO. The issue is that the visual builder does not apply my API key but always uses the default hardcoded one in metabox: AIzaSyC1mUh87SGFyf133tpZQJa-s96p0tgnraQ

    This is a very frustrating issue that is apparently well known: https://support.metabox.io/topic/google-maps-using-default-api-key-mb-settings-page-with-meta-box-groups/

    The fix from that topic didn't help - it's always ignoring my API. I disabled all other plugins with no success. How can I solve this? Why is there a default API at all?

    #30469
    ViktorViktor
    Participant

    After further research, I realised the issue is coming from MB Views actually. If I show the map using rwmb_meta it works fine, however, using MB Views as a shortcode containing this: {{ post.mb_sites_map.rendered }} always uses the hardcoded Maps API key in metabox and ignores mine in the MB Builder.

    How can we use MB Views for Google Maps with our own API key then?

    #30473
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thank you for your feedback.

    Please use the helper function in View to render the map with your API key. I will inform the development team to fix this issue when adding Google Map from the Insert Fields tab.

    {{ mb.rwmb_meta( 'google_map' ) }}
    
    #30475
    ViktorViktor
    Participant

    Thanks Long!
    Can I pass all the js_options this way as well? Could we also use these options with standard Views methods?

    #30486
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Yes, you can add the second argument to the helper function to pass js_options when outputting the map.

    {% set map_args = { width: '640px', height: '480px', js_options: { mapTypeID: 'HYBRID', zoomControl: 'false' } } %}
    {{ mb.rwmb_meta( 'google_map', map_args ) }}

    Get more details on the documentation https://docs.metabox.io/fields/map/#template-usage
    https://twig.symfony.com/doc/3.x/templates.html

    #30702
    Jeremy ParrottJeremy Parrott
    Participant

    Has there been any progress on this? I am currently having the same issue where the map.rendered tag is not displaying my map...

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