﻿
    
    
    //<![CDATA[

    if (GBrowserIsCompatible()) {
      
      // this variable will collect the html which will eventualkly be placed in the sidebar
      var sidebar_html = "";
    
      // arrays to hold copies of the markers and html used by the sidebar
      // because the function closure trick doesnt work there
      var gmarkers = [];
      var htmls = [];
      var i = 0;


      // A function to create the marker and set up the event window
      function createMarker(point,name,html) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        
        // The new marker "mouseover" listener        
//        GEvent.addListener(marker,"mouseover", function() {
//          marker.openInfoWindowHtml(html);
//        });    
        
        // The new marker "close" listener        
        GEvent.addListener(marker, "dblclick", function() {
          map.closeInfoWindow();
        });    
        
        // save the info we need to use later for the sidebar
        gmarkers[i] = marker;
        htmls[i] = html;
        // add a line to the sidebar html
        sidebar_html += '<li><a href="javascript:myclick(' + i + ')">' + name + '</a></li>';
        i++;
        return marker;
      }


      // This function picks up the click and opens the corresponding info window
      function myclick(i) {
        gmarkers[i].openInfoWindowHtml(htmls[i]);
      }


      // Display the map, with some controls and set the initial location 
      var map = new GMap(document.getElementById("map"));
      map.setMapType(G_SATELLITE_MAP); 
      map.addControl(new GLargeMapControl());
      map.addControl(new GScaleControl());
      map.addControl(new GOverviewMapControl());   
      map.addControl(new GMapTypeControl()); 
      GEvent.addListener(map, "moveend", function() {
        var center = map.getCenterLatLng();
        var latLngStr = '目前地圖中心點位置經緯度: ( ' + center.x + ', ' + center.y + ' ) - - &copy; 2006 Mike Lin - - <a href="mailto:golden360@hotmail.com">合作提案</a>';
        document.getElementById("message").innerHTML = latLngStr;
      });      
      map.centerAndZoom(new GPoint(26.015625, 34.59704151614417), 15);

      // add the points   

  
      var point = new GPoint(121.56500816345215, 25.03338889219325);
      var marker = createMarker(point,'1. 台灣 台北 台北101','台灣 台北 台北101')
      map.addOverlay(marker);   
      
      var point = new GPoint(101.7128849029541, 3.1570564174920443);
      var marker = createMarker(point,'2. 馬來西亞 吉隆坡 雙子星塔','馬來西亞 吉隆坡 雙子星塔')
      map.addOverlay(marker);  
      
      var point = new GPoint(-87.63551473617554, 41.879227272406126);
      var marker = createMarker(point,'3. 美國 芝加哥 希爾斯大廈','美國 芝加哥 希爾斯大廈')
      map.addOverlay(marker);    
      
      var point = new GPoint(121.50134325027466, 31.23788482444104);
      var marker = createMarker(point,'4. 中國 上海 金貿大樓','中國 上海 金貿大樓')
      map.addOverlay(marker);      
      
      var point = new GPoint(114.15975093841553, 22.28631677565795);
      var marker = createMarker(point,'5. 中國 香港 國際金融中心二期','中國 香港 國際金融中心二期')
      map.addOverlay(marker);    
      
      var point = new GPoint(113.31933975219726, 23.145499891171663);
      var marker = createMarker(point,'6. 中國 廣州 中信廣場','中國 廣州 中信廣場')
      map.addOverlay(marker);    
      
      var point = new GPoint(114.1060745716095, 22.545240397089596);
      var marker = createMarker(point,'7. 中國 深圳 信興廣場地王大廈','中國 深圳 信興廣場地王大廈')
      map.addOverlay(marker); 
      
      var point = new GPoint(-73.98502349853515, 40.74841114665149);
      var marker = createMarker(point,'8. 美國 紐約 帝國大廈','美國 紐約 帝國大廈')
      map.addOverlay(marker);     
      
      var point = new GPoint(114.17405247688293, 22.280161655047806);
      var marker = createMarker(point,'9. 中國 香港 中環廣場','中國 香港 中環廣場')
      map.addOverlay(marker);   
      
      var point = new GPoint(114.16191279888153, 22.27929793096182);
      var marker = createMarker(point,'10. 中國 香港 中銀大廈','中國 香港 中銀大廈')
      map.addOverlay(marker);   
      

                       
      // put the assembled sidebar_html contents into the sidebar div
      document.getElementById("sidebar").innerHTML = sidebar_html;
      
    }

    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }

    // This Javascript is based on code provided by the
    // Blackpool Community Church Javascript Team
    // http://www.commchurch.freeserve.co.uk/   
    // http://www.econym.demon.co.uk/googlemaps/

    //]]>

