$(document).ready(
  function() 
  { 

    // googlemaps
    if (GBrowserIsCompatible()) {
      var map = new google.maps.Map2($("#map_canvas").get(0)); 
      var gemeentenoordwijkerhout = new GLatLng(52.263679,4.493988);
      map.setCenter(gemeentenoordwijkerhout, 10);
      map.setUIToDefault();
      map.setMapType(G_NORMAL_MAP);

      var bounds = new GLatLngBounds();
      var navigation_html = '<ul>';

      $('#map_data div.marker').each(
        function() {
          //alert($('div.icontype', this).text());
          //alert($('div.lat', this).text());
          //alert($('div.lng', this).text());
          //alert($('div.balloon', this).html());

          var lat = parseFloat($('div.lat', this).text());
          var lng = parseFloat($('div.lng', this).text());
          var point = new GLatLng(lat,lng);

          // Zoom level en Centermap
          bounds.extend(point);	
          map.setZoom(map.getBoundsZoomLevel(bounds) - 1);
		       
          map.setCenter(bounds.getCenter());          

          // Icon type 
          var icontype = $('div.icontype', this).text();

          // Creating the icon
          var icon = new GIcon();
          icon.iconSize = new GSize(24, 24);
          icon.iconAnchor = new GPoint(0, 20);
          icon.infoWindowAnchor = new GPoint(12, 1);
          if (icontype == 'WEGWERKZAAMHEDEN'){
            icon.image = "/img/map_wegwerkzaamheden.png";
          }
          if (icontype == 'HUISVUIL'){
            icon.image = "/img/map_huisvuil.png";
          }
          if (icontype == 'PARKEERMOGELIJKHEDEN'){
             icon.image = "/img/map_parkeren.png";
          }
          if (icontype == 'OVERDEKTPARKEERMOGELIJKHEDEN'){
             icon.image = "/img/map_overdekt_parkeren.png";
          }
          if (icontype == 'WINKELS'){
            icon.image = "/img/map_winkel.png";
          }
          if (icontype == 'GREENICON'){
            icon.image = "/img/map_greenicon.png";
          }
          if (icontype == 'VIERBLAU'){
            icon.image = "/img/SOM_vierkant_blauw.png";
         }
          if (icontype == 'RONDGROE'){
            icon.image = "/img/SOM_rond_groen.png";
}
          if (icontype == 'DRIEGEEL'){
            icon.image = "/img/SOM_driehoek_geel.png";
}
          if (icontype == 'DRIEROOD'){
            icon.image = "/img/SOM_driehoek_rood.png";


          }

          // Create the marker.
          var marker = new GMarker(point,icon);
          var html = $('div.balloon', this).html();
          GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml(html, {maxWidth:250});
          });

          map.addOverlay(marker);
          
        }
      );
    }
  }
);


$(document.body).unload(
  function() 
  {
    // googlemaps unload
    if (GBrowserIsCompatible()) {
      GUnload();
    }
  }
);


