<?php

$args = array(
		'class'=>'',
		'animate'=>'',
		'image'=>'',
		'latitude'=>'',
		'longitude'=>'',
		'address'=>'',
		'map_url'=>'',
		'margin'=>'',					
);

$html = "";


extract(shortcode_atts($args, $atts));

    $dot="'";

    if($animate == "yes"){ 
    $bauen_animate_start = '<div class="animate-box" data-animate-effect="fadeInUp">';
    $bauen_animate_end = '</div>';
    } else {
	$bauen_animate_start="";
	$bauen_animate_end="";		
	}
	
	if(is_numeric($image)) {
		$bauen_image = wp_get_attachment_url( $image );
	} else {
		$bauen_image = $image;
	}
		
		$map_url_opt="";
		if($map_url == "st2"){
		$map_url_opt="//{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png";
		}
		else if($map_url == "st3"){
		$map_url_opt="//{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png";	
		}
		else {
		$map_url_opt="//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";	
		}
		
		$html .='<div class="sec-gmap mb-30 '.esc_attr($class).'"';
				if($margin != '') { $html .='style="margin:'.$margin.';"';} 
		$html .='>'; 		
			$html .=''.$bauen_animate_start.''; 			
				$html .= '<div class="map-container">
							<div id="map-single" class="map" data-map-back="'.$map_url_opt.'" data-latlog="['.$latitude.']" data-popuptext="'.esc_attr($address).'"  data-popupicon="'.esc_url($bauen_image).'"></div>				
					</div>';		
			$html .=''.$bauen_animate_end.''; 		
	    $html .='</div>';  
		
		wp_enqueue_script( 'map-min' );	
        wp_enqueue_script( 'bauen-map-script' );			

echo $html;