function initMaps() {
  $("div.map").each(function() {
    // Hämta in data från koden som Umbraco genererat
    var mapId = $(this).attr('id');

    var value = $(this).html();
    value = $.trim(value);

    var point = value.split(',');

    var lat = parseFloat(point[0]);
    var lon = parseFloat(point[1]);
    var zoom = parseFloat(point[2]);

    // Sätt options för Google Maps v3
    var options = {
      zoom: zoom,
      scrollwheel: false,
      center: new google.maps.LatLng(lat, lon),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    // Skapa kartan (Google Maps v3)
    var map = new google.maps.Map(document.getElementById(mapId), options);
    
    // Marker sizes are expressed as a Size of X,Y
    // where the origin of the image (0,0) is located
    // in the top left of the image.

    // Origins, anchor positions and coordinates of the marker
    // increase in the X direction to the right and in
    // the Y direction down.
    var image = new google.maps.MarkerImage('/images/image.png',
    // This marker is 59 pixels wide by 92 pixels tall.
    new google.maps.Size(59, 92),
    // The origin for this image is 0,0.
    new google.maps.Point(0, 0),
    // The anchor for this image is the base of the flagpole at 0,32.
    new google.maps.Point(30, 92));

    var shadow = new google.maps.MarkerImage('/images/shadow.png',
    // The shadow image is larger in the horizontal dimension
    // while the position and offset are the same as for the main image.
      new google.maps.Size(105, 92),
      new google.maps.Point(0, 0),
      new google.maps.Point(30, 92));
    // Shapes define the clickable region of the icon.
    // The type defines an HTML <area> element 'poly' which
    // traces out a polygon as a series of X,Y points. The final
    // coordinate closes the poly by connecting to the first
    // coordinate.
    var shape = {
      coord: [54, 0, 56, 1, 57, 2, 57, 3, 58, 4, 58, 5, 58, 6, 58, 7, 58, 8, 58, 9, 58, 10, 58, 11, 58, 12, 58, 13, 58, 14, 58, 15, 58, 16, 58, 17, 58, 18, 58, 19, 58, 20, 58, 21, 58, 22, 58, 23, 58, 24, 58, 25, 58, 26, 58, 27, 58, 28, 58, 29, 58, 30, 58, 31, 58, 32, 58, 33, 58, 34, 58, 35, 58, 36, 58, 37, 58, 38, 58, 39, 58, 40, 58, 41, 58, 42, 58, 43, 58, 44, 58, 45, 58, 46, 58, 47, 58, 48, 58, 49, 58, 50, 58, 51, 58, 52, 58, 53, 58, 54, 58, 55, 58, 56, 58, 57, 58, 58, 58, 59, 57, 60, 57, 61, 56, 62, 54, 63, 35, 64, 35, 65, 35, 66, 35, 67, 34, 68, 34, 69, 34, 70, 34, 71, 33, 72, 33, 73, 33, 74, 33, 75, 32, 76, 32, 77, 32, 78, 32, 79, 31, 80, 31, 81, 31, 82, 31, 83, 30, 84, 30, 85, 30, 86, 30, 87, 29, 88, 29, 89, 29, 90, 29, 91, 29, 91, 29, 90, 29, 89, 29, 88, 28, 87, 28, 86, 28, 85, 28, 84, 27, 83, 27, 82, 27, 81, 27, 80, 26, 79, 26, 78, 26, 77, 26, 76, 25, 75, 25, 74, 25, 73, 25, 72, 24, 71, 24, 70, 24, 69, 24, 68, 23, 67, 23, 66, 23, 65, 23, 64, 4, 63, 2, 62, 1, 61, 1, 60, 0, 59, 0, 58, 0, 57, 0, 56, 0, 55, 0, 54, 0, 53, 0, 52, 0, 51, 0, 50, 0, 49, 0, 48, 0, 47, 0, 46, 0, 45, 0, 44, 0, 43, 0, 42, 0, 41, 0, 40, 0, 39, 0, 38, 0, 37, 0, 36, 0, 35, 0, 34, 0, 33, 0, 32, 0, 31, 0, 30, 0, 29, 0, 28, 0, 27, 0, 26, 0, 25, 0, 24, 0, 23, 0, 22, 0, 21, 0, 20, 0, 19, 0, 18, 0, 17, 0, 16, 0, 15, 0, 14, 0, 13, 0, 12, 0, 11, 0, 10, 0, 9, 0, 8, 0, 7, 0, 6, 0, 5, 0, 4, 1, 3, 1, 2, 2, 1, 4, 0],
      type: 'poly'
    };

    // Skapa en markör och positionera den på kartan  
    var marker = new google.maps.Marker({
      position: new google.maps.LatLng(lat, lon),
      map: map,
      shadow: shadow,
      icon: image,
      title: 'Kärnhuset',
      clickable: true
    });

    var contentString = '<div id="content" style="position: relative"><p>Kärnhuset<br />Götgatan 36<br />118 26 Stockholm<br />Tel: 08-23 82 00</p></div>';
    var infoWin = new google.maps.InfoWindow({
      content: contentString
    });

    google.maps.event.addListener(marker, 'click', function() {
      infoWin.open(map,marker);
    });

    /*var trafficLayer = new google.maps.TrafficLayer();
    trafficLayer.setMap(map);*/

  });
}

$(document).ready( function(){
  initMaps();
});
