Home Forums WoodMart support forum Google maps – no-controls Reply To: Google maps – no-controls

#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