Home Forums WoodMart support forum Google maps – no-controls

Google maps – no-controls

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #75994

    mponferrada
    Participant

    I need to disable the google maps controls in order to they are not visible. I have seen that the map of the corporate template brought the class ‘no-controls’ but it does not work, they are still visible.

    Attachments:
    You must be logged in to view attached files.
    #75998

    Artem Temos
    Keymaster

    Hello,

    Try to add the following PHP code snippet to the child theme functions.php file to do this

    function woodmart_google_map_init_js( $atts, $id ) {
    	$output = '';
    	extract(shortcode_atts( array(
    		'title' => '',
    		'lat' => 45.9,
    		'lon' => 10.9,
    		'style_json' => '',
    		'zoom' => 15,
    		'scroll' => 'no',
    		'marker_icon' => '',
    		'marker_content' => ''
    	), $atts ));
    
    	if ( $marker_icon ) {
    		$marker_url = wp_get_attachment_image_src( $marker_icon );
    		$marker_icon = $marker_url[0];
    	}else{
    		$marker_icon = WOODMART_ASSETS . '/images/google-icon.png';
    	}
    
    	ob_start();
    	?>
    		jQuery(document).ready(function() {
    
    			new Maplace({
    				locations: [
    				    {
    						lat: <?php echo esc_js( $lat ); ?>,
    						lon: <?php echo esc_js( $lon ); ?>,
    						title: '<?php echo esc_js( $title ); ?>',
    				        <?php if( $title != '' && empty( $content ) ): ?>
    				        	html: <?php echo json_encode( $marker_content ); ?>, 
    				        <?php endif; ?>
    				        icon: '<?php echo esc_js( $marker_icon ); ?>',
    				        animation: google.maps.Animation.DROP
    				    }
    				],
    				controls_on_map: false,
    				title: '<?php echo esc_js( $title ); ?>',
    			    map_div: '.google-map-<?php echo esc_js( $id ); ?>',
    			    start: 1,
    			    map_options: {
    			        zoom: <?php echo esc_js( $zoom ); ?>,
    			        scrollwheel: <?php echo ($scroll == 'yes') ? 'true' : 'false'; ?>,
    			        disableDefaultUI: true
    			    },
    			    <?php if($style_json != ''): ?>
    			    styles: {
    			        '<?php esc_html_e('Custom style', 'woodmart') ?>': <?php echo rawurldecode( woodmart_decompress($style_json, true) ); ?>
    			    }
    			    <?php endif; ?>
    			}).Load();
    
    		});
    	<?php
    	return ob_get_clean();
    }
    add_shortcode( 'woodmart_google_map', 'woodmart_shortcode_google_map' );

    Regards

    #76006

    mponferrada
    Participant

    It works correctly.
    Thank you

    #76008

    You are welcome! If you have any questions please feel free to contact us.

    Best Regards

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Google maps – no-controls’ is closed to new replies.