<?PHP
$Var="19.6965354";
$Var2="-99.21633610000004";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<meta name="viewport" content="width=620" />
<title>Documento sin título</title>
<meta name="description" content="Demostration of the Geolocation Javascript object">

<style type="text/css">
	#Map
	{
		/*Dimensiones Originales
		width: 98%;
		height: 500px;
		margin: auto;
		border: 1px solid #BBB;*/
		
		width: 58%;
		height: 400px;
		margin: auto;
		border: 1px solid #BBB;
	}	
</style>
	
	<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
	
	<script type="text/javascript">
	
		////////////////////////////////////////////////////////////////////////////////////////////
		
		var map = null;		
				
		////////////////////////////////////////////////////////////////////////////////////////////		

		function init()
		{
			if(!checkGeolocationSupport())
			{
				alert("Sorry but your browser does not have geolocation support.");
			}

			map = setupMap();
		
			findWhereAmI();
		}	
		
		////////////////////////////////////////////////////////////////////////////////////////////		

		function setupMap()
		{
			var theOptions = 
			{
				zoom: 16,
				center: new google.maps.LatLng(4, -72),
				mapTypeControl: false,
				mapTypeId: google.maps.MapTypeId.ROADMAP,
				navigationControlOptions: 
				{
					style: google.maps.NavigationControlStyle.SMALL
				}
			};

			return new google.maps.Map(document.getElementById("Map"), theOptions);
  		}

		////////////////////////////////////////////////////////////////////////////////////////////		
		
		function checkGeolocationSupport()
		{
			return navigator.geolocation;
		}		
		
		function findWhereAmI()
		{
			navigator.geolocation.getCurrentPosition(onSuccessGeolocating, 
			                                         onErrorGeolocating,
			                                         {
			                                         		enableHighAccuracy: true,
			                                         		maximumAge:         5000,
			                                         		timeout:            20000
			                                         });
		}
		
		function onSuccessGeolocating(position)
		{
			var userLocation = new google.maps.LatLng("<?PHP echo $Var; ?>", 
 			                                          "<?PHP echo $Var2; ?>");

			var message = "Entregue Aquí!\n\n" + 
			              "\tLatitude = " + position.coords.latitude + "\n" + 
			              "\tLongitude = " + position.coords.longitude;

			var marker = new google.maps.Marker({
				position: userLocation, 
				map: map, 
				title: message
			});
 			                                          
			map.setCenter(userLocation);
		}
		
		function onErrorGeolocating(error)
		{
			switch(error.code)
			{
				case error.PERMISSION_DENIED:
					alert('ERROR: User denied access to track physical position!');
				break;
				
				case error.POSITION_UNAVAILABLE:
					alert("ERROR: There is a problem getting the position of the device!");
				break;
				
				case error.TIMEOUT:
					alert("ERROR: The application timed out trying to get the position of the device!");
				break;
				
				default:
					alert("ERROR: Unknown problem!");
				break;
			}
		}
	
	</script>
</head>

<body onload="init()">
<?PHP
echo"Prueba 7:<Br><Br>";
?>


<Br>


				<div id="Map">&nbsp;</div>

        
</body>
</html>