<?php

	function ventoux_maps($atts, $content = null) {
		
		extract(shortcode_atts(array(
				'mapid'			=> '',
				'location'		=> '',
				'height'		=> '',
				'zoom'			=> '',
				'title'			=> '',
		), $atts));	

		wp_enqueue_scripts('vidall_googlemap');
		wp_enqueue_scripts('vidall_googlemap_fire');
				
		{

			
		$address = urlencode($location);
			$request_url = "http://maps.googleapis.com/maps/api/geocode/xml?address=".$location."&sensor=true";
				$xml = simplexml_load_file($request_url) or die("url not loading");
				$status = $xml->status;
				if ($status=="OK") {
					$Lat = $xml->result->geometry->location->lat;
					$Lon = $xml->result->geometry->location->lng;
						$LatLng = "$Lat,$Lon";
					
  }
		$map = '<div class="vf_map_wrapper" style="height: '.$height.'px;">';		
		$map .= "<script>// <![CDATA[ \n";
    	$map .= "function initialize() { \n";
		$map .= "var myLatlng = new google.maps.LatLng(" . $LatLng . "); \n";
		$map .= "var mapOptions = { \n";
		$map .= "zoom: ". $zoom . ",\n";
		$map .= "center: myLatlng\n";
		$map .= "}; \n";
		$map .= " var map = new google.maps.Map(document.getElementById('$mapid'), mapOptions); \n";
		$map .= " var marker = new google.maps.Marker({ \n";
		$map .= "position: myLatlng,\n";
		$map .= "map: map,"	;
		$map .= "title: '" . $title . "'\n";
		$map .= "});\n";
		$map .= "} \n";
		$map .= "google.maps.event.addDomListener(window, 'load', initialize);\n";
		$map .= "// ]]></script>\n"; 
    $map .= "<div class='map-canvas' id='$mapid'></div>";
    $map .= '</div>';
 return $map;
}
		
}
add_shortcode('ventoux_map', 'ventoux_maps');