	var map; 
	
	function mapa() 
	{
		var latlng = new google.maps.LatLng(latitude, longitude);
		var options = {
		  zoom: 15,
		  center: latlng,
		  mapTypeId: google.maps.MapTypeId.SATELLITE
		};
				  
		map = new google.maps.Map(document.getElementById("mapa-portada"), options);

		loadImages();
	}

	    function loadImages()
	    {
			$.getJSON("/panoramio?point="+latitude+","+longitude+"&size=small",
				function(data)
				{
					$.each(data.photos, function(i, photo) 
					{
						var image = new google.maps.MarkerImage('http://mw2.google.com/mw-panoramio/photos/mini_square/'+photo.photo_id+'.jpg',
							new google.maps.Size(32, 32),
							new google.maps.Point(0,0),
							new google.maps.Point(0, 32));
						 
						var shape = {
							coord: [0, 0, 0, 32, 32, 32, 32, 0],
							type: 'poly'
						};
  
						var marker = new google.maps.Marker({
							map: map,
							draggable: false,
							icon: image,
							shape: shape, 
							'position': new google.maps.LatLng(photo.latitude, photo.longitude)
						  });
						
						google.maps.event.addListener(marker, 'click', function() {
							var contentString = "<a href='http://www.panoramio.com'>Panoramio</a><br/><a href='"+photo.photo_url+"'><img src='http://mw2.google.com/mw-panoramio/photos/small/"+photo.photo_id+".jpg' style='border:0' width='" + photo.width + "' height='" + photo.height + "' /></a><div style='width:170px'>Autor: <a href='"+photo.owner_url+"'>"+photo.owner_name+"</a></div>";
							var infowindow = new google.maps.InfoWindow({
								content: contentString
							});
							infowindow.open(map, marker);
						  });
					});
						
				});
		}
		
$(function() { mapa(); });
