Can't display map added through clonable group

Support MB Group Can't display map added through clonable group

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #8102
    aaronaaron
    Participant

    I've created a multi-section group field to allow drag and drop ordering of the metaboxes by the client.

    Everything works fine until I try to call the map. I'm not sure how to add the arguments to the call?

    $cps = rwmb_meta('contact_page_sections');
    foreach ( $cps as $cp ) :
    
    // Map
    $args = array(
        'width'      => '640px',
        'height'     => '480px',
        'js_options' => array(
            'mapTypeId'   => 'HYBRID',
            'zoomControl' => false,
        )
    );
    
    $contact_page_map = isset( $cp["{$prefix}contact_page_map"] ) ? $cp["{$prefix}contact_page_map"] : '';
    
    echo '<section class="map">' . $contact_page_map . '</section>';
    
    endforeach;
    
    #8108
    Anh TranAnh Tran
    Keymaster

    Hi,

    Thanks for a great question. There was no such functions. I've just added it on Github and added example in the documentation. Please update the code for Meta Box from Github and follow the documentation. I will release a new version soon.

    #8113
    aaronaaron
    Participant

    Thank you for the great reply, this has lead to another issue.

    The map won't display if contained within a condition.

    For example if I check to see if an address exists for the map:

    
    $contact_page_map_address = isset( $cp["{$prefix}contact_page_map_address"] ) ? $cp["{$prefix}contact_page_map_address"] : '';
    
    if ( !empty ($contact_page_map_address) ) :
    	$contact_page_map = isset( $cp["{$prefix}contact_page_map"] ) ? $cp["{$prefix}contact_page_map"] : '';
    	// Map Args
    	$args = array(
    	    'width'      => '100%',
    	    'height'     => '480px',
    	    'js_options' => array(
    	        'mapTypeId'   => 'HYBRID',
    	        'zoomControl' => false,
    	    )
    	);
    	$map = RWMB_Map_Field::render_map( $contact_page_map, $args );
    	echo '<section class="map">' . $map . '</section>';
    endif;	
    

    If the condition is removed then the map displays perfectly.
    I look forward to your reply.

    #8116
    aaronaaron
    Participant

    Hi Anh,
    After some head scratching I solved my 2nd issue.
    I had a select menu to choose the content for each of the sections on the page. One of the options was 'map' => 'Map', After changing this to another value it all worked perfectly?

    Thank you for taking the time with my initial problem.

    Aaron.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Can't display map added through clonable group’ is closed to new replies.