﻿ var map;
    var geocoder;

    function initialize() {
      map = new GMap2(document.getElementById("map_canvas"));
      // map.setMapType(G_PHYSICAL_MAP);
      map.setCenter(new GLatLng(35.986896, 139.504395), 10);
      //  map.addControl(new GLargeMapControl());
      //  map.addControl(new GMapTypeControl());
	map.setUIToDefault();
      geocoder = new GClientGeocoder();
map.addControl(new google.maps.LocalSearch("pub-9367831331894417"), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,20)));
    }

    // addAddressToMap() is called when the geocoder returns an
    // answer.  It adds a marker to the map with an open info window
    // showing the nicely formatted version of the address and the country code.
    function addAddressToMap(response) {
      map.clearOverlays();
      if (!response || response.Status.code != 200) {
        alert("住所の場所を特定できませんでした。");
      } else {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        marker = new GMarker(point);
        map.addOverlay(marker);
        marker.openInfoWindowHtml(place.address );
        //  '<b>国コード:</b> ' + place.AddressDetails.Country.CountryNameCode);
 	GEvent.addListener(marker,"click",function(){map.setCenter(point, 13);
      }) ;
window.location.hash = 'top';

    }
   }
    // showLocation() is called when you click on the Search button
    // in the form.  It geocodes the address entered into the form
    // and adds a marker to the map at that location.
    function showLocation(address) {initialize();
      var xaddress = address;
      geocoder.getLocations(xaddress, addAddressToMap);
    }

   // findLocation() is used to enter the sample addresses into the form.
    function findLocation(address) {
      document.forms[0].q.value = address;
      showLocation();
    }