  // Builds an array of geocode responses for the 5 cities.
  var city = [
    {
      name: "台北",
      Status: {
        code: 200,
        request: "geocode"
      },
      Placemark: [
        {
          address: "台北",
          Point: {
            coordinates: [25.128501,121.561661, 0]
          },
          AddressDetails: {
            Country: {
              CountryNameCode: "TW",
              Locality: {LocalityName: "台北"}
            }
          }
        }
      ]
    },
    {
      name: "高雄",
      Status: {
        code: 200,
        request: "geocode"
      },
      Placemark: [
        {
          address: "高雄",
          Point: {
            coordinates: [22.665343,120.324326, 0]
          },
            AddressDetails: {
            Country: {
              CountryNameCode: "TW",
              Locality: {LocalityName: "高雄"}
            }
          }
        }
      ]
    },
  ];

  // CapitalCitiesCache is a custom cache that extends the standard GeocodeCache.
  // We call apply(this) to invoke the parent's class constructor.
  function CapitalCitiesCache() {
    GGeocodeCache.apply(this);
  }

  // Assigns an instance of the parent class as a prototype of the
  // child class, to make sure that all methods defined on the parent
  // class can be directly invoked on the child class.
  CapitalCitiesCache.prototype = new GGeocodeCache();

  // Override the reset method to populate the empty cache with
  // information from our array of geocode responses for capitals.
  CapitalCitiesCache.prototype.reset = function() {
    GGeocodeCache.prototype.reset.call(this);
    for (var i in city) {
      this.put(city[i].name, city[i]);
    }
  }

    var map = null;
    var geocoder = null;

    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
    	map.setCenter(new GLatLng(25.041438, 121.555910), 16);
        geocoder = new GClientGeocoder();
    	geocoder.setCache(new CapitalCitiesCache());
      }
    }
	
    function showAddress() {
      if (geocoder) {
        geocoder.getLatLng(
          Gmap_addr,
          function(point) {
            if (!point) {
              document.getElementById("map_msg").innerHTML="很抱歉，此地址未能找到： " + Gmap_addr;
            } else {
              map.setCenter(point, 16);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml(Gmap_tel +'<br />' + Gmap_addr);
            }
          }
        );
      }
    }
