// places.js
// Javascript functions to plot points for the Google Maps API
// By Brian Baker
// .
// Some portions of this code was copied from other sources


    //Function to create a marker object.
    function createMarker(myIcon, myZoom, myName, myLat, myLong) {
      var myPoint = new GLatLng(myLat, myLong);
      var myMarker = new GMarker(myPoint, {clickable:true, icon:myIcon, title:myName});
      //var myUrl = "http://maps.google.com/?ie=UTF8&t=h&om=1&ll=" + myLat + "," + myLong + "&spn=0.724338,1.332092";
      //GEvent.addListener(myMarker, "click", function() { window.open(myUrl); });
      GEvent.addListener(myMarker, "click", function() { myZoom.setCenter(myPoint, 11); });

      return myMarker;
    }

//function zoomMap(myZoom, myPoint) {
//  myZoom.setCenter(myPoint, 11);
//}

function load() {
  if (GBrowserIsCompatible()) {
    //Create a map object.
    var map = new GMap2(document.getElementById("map"));
    //map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    map.disableDragging();
    map.setCenter(new GLatLng(10.00, 0.00), 2, G_SATELLITE_MAP);

    //Create a zoomed map object.
    var zoom = new GMap2(document.getElementById("zoom"));
    //var myType = new GMapType();
    //zoom.addControl(new GSmallMapControl());
    //zoom.addControl(new GMapTypeControl());
    zoom.disableDragging();
    zoom.setCenter(new GLatLng(38.890064, -77.010974), 16, G_SATELLITE_MAP);
    //zoom.setMapType(G_HYBRID_MAP);

    //Create a custom icon object
    var icon = new GIcon();
    icon.image = "graphics/iconr.png";
    //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
    icon.iconSize = new GSize(12, 20);
    //icon.shadowSize = new GSize(22, 20);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);

    //Create an array of markers.
    var gPlace = new Array();
    var i=0;
    //gPlace[i++] = new createMarker("", );
    gPlace[i++] = new createMarker(icon, zoom, "Vienna", 48.21049,16.386795);
    gPlace[i++] = new createMarker(icon, zoom, "Kailua", 19.615748,-155.976334);
    gPlace[i++] = new createMarker(icon, zoom, "Yellow Stone National Park", 44.460388,-110.827975);
    gPlace[i++] = new createMarker(icon, zoom, "Ensenada", 31.860478,-116.625034);
    gPlace[i++] = new createMarker(icon, zoom, "Bern", 46.946981,7.45182);
    gPlace[i++] = new createMarker(icon, zoom, "Rota", 36.62655,-6.354733);
    gPlace[i++] = new createMarker(icon, zoom, "Pearl Harbor", 21.362292,-157.94632);
    gPlace[i++] = new createMarker(icon, zoom, "Victoria", 48.419632,-123.373032);
    gPlace[i++] = new createMarker(icon, zoom, "Eugene", 44.049658,-123.08979);
    gPlace[i++] = new createMarker(icon, zoom, "Jabal Ali", 24.98917,55.064163);
    gPlace[i++] = new createMarker(icon, zoom, "Bahrain", 26.194877,50.583801);
    gPlace[i++] = new createMarker(icon, zoom, "Phuket", 7.8962,98.297253);
    gPlace[i++] = new createMarker(icon, zoom, "Singapore", 1.30254,103.86878);
    gPlace[i++] = new createMarker(icon, zoom, "Souda Bay", 35.530794,24.164429);
    gPlace[i++] = new createMarker(icon, zoom, "Mombasa", -4.028659,39.599705);
    gPlace[i++] = new createMarker(icon, zoom, "Hobart", -42.9064,147.358246);
    gPlace[i++] = new createMarker(icon, zoom, "Perth", -32.013607,115.785084);
    gPlace[i++] = new createMarker(icon, zoom, "US Naval Station, Guantanamo Bay", 19.943015,-75.160046);
    gPlace[i++] = new createMarker(icon, zoom, "Hong Kong", 22.294973,114.178162);
    gPlace[i++] = new createMarker(icon, zoom, "Naples", 40.877155,14.286454);

    //for (n=0; n<i; n++) {
    //  var p = new GPoint(gPlace[n].getPoint());
    //  GEvent.addListener(gPlace[n], "click", function() { zoom.setCenter(p, 11); } );

    //}
    //Place each marker on the map.
    for (n=0; n<i; n++) {
      map.addOverlay(gPlace[n]);
    }
  }
}


