function addMarker(data){
   var newpoint = new GLatLng(data.lat,data.lng);  
   var myIcon = new GIcon(G_DEFAULT_ICON);
   if( data.tipo == 166 ){
      if( data.provincia == "TN" ){
          myIcon.image = "/assets/super.png";
			 data.html = "superstore/" + data.html; 
      } else {
          myIcon.image = "/assets/iper.png";
			 data.html = "ipermercato/" + data.html; 
      }                       
   } else {
      myIcon.image = "/assets/coop.png";
		data.html = "supermercato/" + data.html; 
   }
   myIcon.iconSize = new GSize(21, 35);
   myIcon.iconAnchor = new GPoint(14, 27);
   myIcon.iconAnchor = new GPoint(21, 35);
   myIcon.imageMap =[ 20, 15, 20, 5, 15, 0, 5, 0, 0, 5, 0, 16, 7, 22, 11, 22, 14, 27 ];
   var markerOptions = { icon:myIcon };
   var marker = new GMarker( newpoint,  { icon: myIcon, title: data.nome, html: data.html  } );
   GEvent.addListener(marker, "click", function() {
      window.location = "/"+data.html+"/index.htm";
   });
   return marker;
}

function loadPointsOnMap( data ){
   map.clearOverlays();
   var bounds = new GLatLngBounds();
   for( i = 0; i < data.length; i++ ){
      map.addOverlay( addMarker( data[i] ) );
      var newpoint = new GLatLng(data[i].lat,data[i].lng);  
      bounds.extend( newpoint );
   }
   map.setCenter(bounds.getCenter(),map.getBoundsZoomLevel(bounds) , G_NORMAL_MAP ) ;
   if( data.length <= 1 ){
      map.setCenter(bounds.getCenter(),map.getBoundsZoomLevel(bounds) - 7 , G_NORMAL_MAP ) ;
   } else {
      map.setCenter(bounds.getCenter(),map.getBoundsZoomLevel(bounds) , G_NORMAL_MAP ) ;
   }
}



;


;
;
;


;
;


;
;

