google maps vs. include/exclude

Support MB Geolocation google maps vs. include/exclude

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #5448
    web-crossingweb-crossing
    Participant

    Hi,
    if I add a dynamic google maps via a selectable box the API-Key gets lost (nasty description).

    So - if i have folling definition the map is not shown but the javascript error message that no API-Key is given.
    If i remove the 'hidden'-statement the map is shown as usual.

    best regards,
    niko

                array(
                    'id'   =>  "{$prefix}address",
                    'name' => __( 'Address', 'webx' ),
                    'type' => 'text',
                    'std'  => __( 'Innsbruck, Austria', 'webx' ),
                    'hidden' => array( "{$prefix}type", '!=', 4),
                ),
                array(
                    'id'            =>  "{$prefix}map",
                    'name'          => __( 'Location', 'webx' ),
                    'type'          => 'map',
                    'std'           => '47.2643292,11.3963643',
                    'address_field' => "{$prefix}address",
                    'api_key'       => 'super-fancy-google-maps-key',
                    'hidden' => array( "{$prefix}type", '!=', 4),
                ),
    #5470
    Tan NguyenTan Nguyen
    Participant

    Dear Web Crossing,

    Can you please send me full code. I've tried added your two fields to the example and it works.
    https://gist.github.com/anonymous/0c6aad33f510e491dd4604cd1beb74fa

    Cheers!

    #5483
    web-crossingweb-crossing
    Participant

    Hi,
    here you go:

    <?php

    
    function content_element_metaboxes( $meta_boxes ) {
        $prefix = "webx-";
        $type_opt = array(0 => "Text", 1 => "Masonry Gallery", 2 => "Slider", 3 => "Big Picture", 4 => "Map", 5 => "Insta Feed", 6 => "Cite", 7 => "Interview");
    
        $just_text = array(
            'wpautop' => false,
            'media_buttons' => true,
            'textarea_rows' => 20,
            'teeny' => false,
            'dfw' => false,
            'tinymce' => true,
            'quicktags' => false
        );
    
        $meta_boxes[] = array(
            'title'      => __('The content', 'webx'),
            'context'    => 'normal',
            'priority'   => 'high',
            'post_types' => array( 'content_element'),
            'geo' => true,
            'fields' => array(
                array(
                    'name' => __('Type', 'webx'),
                    'id' => "{$prefix}type",
                    'type'  => "select",
                    'inline' => true,
                    'options' => $type_opt
                ),
                array(
                    'name' => __('Text', 'webx'),
                    'id' => "{$prefix}text",
                    'type'  => "wysiwyg",
                    'options' => $just_text,
                    'hidden' => array( "{$prefix}type", '!=', 0)
                ),
                array(
                    'id'               => "{$prefix}gallery",
                    'name'             => __('Images', 'webx'),
                    'type'             => 'image_advanced',
                    'force_delete'     => false,
                    'max_file_uploads' => 50,
                    'max_status'       => true,
                    'visible' => array( "{$prefix}type", 'in', [1, 2, 3])
                ),
                // Map requires at least one address field (with type = text)
                array(
                    'id'   =>  "{$prefix}address",
                    'name' => __( 'Address', 'webx' ),
                    'type' => 'text',
                    'std'  => __( 'Innsbruck, Austria', 'webx' ),
                    'visible' => array( "{$prefix}type", 4),
                ),
                array(
                    'id'            =>  "{$prefix}map",
                    'name'          => __( 'Location', 'webx' ),
                    'type'          => 'map',
                    'std'           => '47.2643292,11.3963643',
                    'address_field' => "{$prefix}address",
                    'api_key'       => 'AIzaSyBQDh2E_g4_UTvYb5_2y6WClAOCn3VqRLc',
                    'visible' => array( "{$prefix}type", 4),
                ),
                array(
                    'name' => __('Markers', 'webx'),
                    'id' => "{$prefix}markers",
                    'type' => 'group',
                    'clone'  => true,
                    'visible' => array( "{$prefix}type", 4),
                    'fields' => array(
                        array(
                            'name' => __('Address', 'webx'),
                            'type' => 'text',
                            'id'    => 'address_marker'
                        ),
                        array(
                            'name' => __('Text', 'webx'),
                            'type' => 'wysiwyg',
                            'id'    => 'markercontent',
                            'options' => $just_text
                        ),
                    ),
                ),
                array(
                    'id'   =>  "{$prefix}instagram",
                    'name' => __( 'Instagram ID', 'webx' ),
                    'dec' => __('get it here: ') . ".https://smashballoon.com/instagram-feed/find-instagram-user-id/",
                    'type' => 'text',
                    'size' => 100,
                    'hidden' => array( "{$prefix}type", '!=', 5),
                ),
                array(
                    'id'   =>  "{$prefix}cite",
                    'name' => __( 'cite', 'webx' ),
                    'type' => 'textarea',
                    'size' => 100,
                    'hidden' => array( "{$prefix}type", '!=', 6),
                ),
                array(
                    'id' => "{$prefix}interview-header",
                    'name' => __("Title", 'webx'),
                    'type' => 'text',
                    'size' => 120,
                    'hidden' => array( "{$prefix}type", '!=', 7),
                ),
                array(
                    'id' => "{$prefix}interview",
                    'name' => __("Interview", 'webx'),
                    'type' => 'group',
                    'hidden' => array( "{$prefix}type", '!=', 7),
                    'sort_clone' => true,
                    'clone'  => true,
                    'fields' => array(
                        array(
                            'name' => __('Question', 'webx'),
                            'type' => 'text',
                            'size' => 80,
                            'id'    => 'question'
                        ),
                        array(
                            'name' => __('Text', 'webx'),
                            'type' => 'wysiwyg',
                            'id'    => 'answer',
                            'options' => $just_text
                        ),
                    )
    
                )
    
            )
        );
        return $meta_boxes;
    }
    add_filter( 'rwmb_meta_boxes', 'content_element_metaboxes' );
    #5489
    Tan NguyenTan Nguyen
    Participant

    Hi,

    It works on my PC, did you:

    - Use the latest plugins version?
    - See any error in the console?

    Cheers!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘google maps vs. include/exclude’ is closed to new replies.