<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="<?=prep_url(base_url())?>application/template/modules/modules_js/gmap3-min.js" ></script>


<script type="text/javascript">
$(document).ready(function() {

	
	var map1;
	//var infowindow1, infowindow2;
	<?php
	$latlng = ''; $count = 0;
	if($content && $content->num_rows() > 0)
		foreach($content->result() as $row) {
			if($count == 0) $latlng .= 'center:['.$row->mapa_lat.','.$row->mapa_lng.'],';
				
			echo 'var infowindow'.$row->ID_mapa.';
			'; 
			$count++;
		}
	?>
	
	$('#test')
	.show()
	  .gmap3(
	  { action:':init',
	    options:{

	      <?=$latlng?>
	      zoom: 5
	    },
	    callback: function($e, map){
	      map1 = map;
	    }
	  },
  <?php if($content && $content->num_rows() > 0)
		foreach($content->result() as $row) { ?>
		{
			action: ':addMarker',
			latLng:[<?=$row->mapa_lat?>,<?=$row->mapa_lng?>],
			marker:{
				options:{
					draggable: true
				},
				events:{
					click: function($e, marker){
						infowindow<?=$row->ID_mapa?>.open(map1, marker);
					}
				}
			},
			infowindow: {
				open: false,
				options:{
					content: '<h3><?=$row->mapa_tytul?></h3><p><?=$row->mapa_opis?></p>'
				},
				callback: function($e, infowindow){
					infowindow<?=$row->ID_mapa?> = infowindow;
				}
			}
		},
	<?php } ?>
	 
	  
	  {action: 'setOptions', args:[{scrollwheel:true}]}
	);

		
});

</script>

<div style="background:#FFF; border:1px solid #CCC; padding:10px;">
	<div id="test" style="height:250px;"></div>
</div>
