    //<![CDATA[

    // Our global state
    var gLocalSearch;
    var gMap;
    var gSelectedResults = [];
    var gCurrentResults = [];
    var address;


    // Create our "tiny" marker icon
    var gSmallIcon = new GIcon();
    gSmallIcon.image = "mm_20_red.png";
    gSmallIcon.shadow = "mm_20_shadow.png";
    gSmallIcon.iconSize = new GSize(12, 20);
    gSmallIcon.shadowSize = new GSize(22, 20);
    gSmallIcon.iconAnchor = new GPoint(6, 20);
    gSmallIcon.infoWindowAnchor = new GPoint(5, 1);

    // Set up the map and the local searcher.
    function OnLoad() {
var lat =  35.6867816;
var lng = 139.7628092;
      // var input = document.getElementById("jzahyou");
      // input.focus();

      // Initialize the map
      gMap = new GMap(document.getElementById("map"));
gMap.addControl(new GScaleControl());
gMap.addControl(new GOverviewMapControl());
      gMap.addControl(new GLargeMapControl());
      gMap.addControl(new GMapTypeControl(true));
var centerPoint = new GLatLng(lat, lng);
gMap.setCenter(centerPoint, 15);

      gMap.enableDoubleClickZoom();
      gMap.enableContinuousZoom();

    //十字アイコン作成
    var icon = new GIcon();
    icon.image = "./cross2.png";
    icon.iconSize = new GSize(20, 20);
    icon.iconAnchor = new GPoint(10, 10);
    var marker = new GMarker(gMap.getCenterLatLng(), icon);
    gMap.addOverlay(marker);
    
    //イベント追加
    GEvent.addListener(gMap, "move", function() { 
       //今あるオーバーレイをクリア
       gMap.removeOverlay(marker) 
       //新しい位置のアイコンマーカー生成
       marker = new GMarker(gMap.getCenterLatLng(), icon);
       //新しいオーバーレイを追加
       gMap.addOverlay(marker);
    });


      // Initialize the local searcher
      gLocalSearch = new GlocalSearch();
      gLocalSearch.setCenterPoint(gMap);
      gLocalSearch.setSearchCompleteCallback(null, OnLocalSearch);

      // Execute the initial search
//      gLocalSearch.execute(input.value);
    }

    // Called when Local Search results are returned, we clear the old
    // results and load the new ones.
    function OnLocalSearch() {
      if (!gLocalSearch.results) {
        window.alert("「"+document.getElementById("jzahyou").value+"」は見つかりませんでした");
//        document.getElementById("jzahyou").value = "";
        return false;
      }
      var searchWell = document.getElementById("searchwell");

      // Clear the map and the old search well
      searchWell.innerHTML = "";
      for (var i = 0; i < gCurrentResults.length; i++) {
        if (!gCurrentResults[i].selected()) {
          gMap.removeOverlay(gCurrentResults[i].marker());
        }
      }

      gCurrentResults = [];
      for (var i = 0; i < gLocalSearch.results.length; i++) {
        gCurrentResults.push(new LocalResult(gLocalSearch.results[i]));
      }
      // move the map to the first result
      var first = gLocalSearch.results[0];
      if(typeof(first) == "undefined") {
        window.alert("「"+document.getElementById("jzahyou").value+"」は見つかりませんでした");
//        document.getElementById("jzahyou").value = "";
        return false;
      }
      gMap.recenterOrPanToLatLng(new GLatLng(parseFloat(first.lat), parseFloat(first.lng)));
      return true;
    }

    function Getlatlang(form) {
      var centerlatlng = gMap.getCenterLatLng();
// document.write("lat=",centerlatlng.x);
      form["clat"].value = centerlatlng.y;
      form["clng"].value = centerlatlng.x;
      if(address != "") form["adr"].value = address;
      return true;
    }

    // A class representing a single Local Search result returned by the
    // Google AJAX Search API.
     function LocalResult(result) {
       this.result_ = result;
       this.resultNode_ = this.unselectedHtml();
       document.getElementById("searchwell").appendChild(this.resultNode_);
       gMap.addOverlay(this.marker(gSmallIcon));
     }

    // Returns the GMap marker for this result, creating it with the given
    // icon if it has not already been created.
    LocalResult.prototype.marker = function(opt_icon) {
      if (this.marker_) return this.marker_;
      var marker = new GMarker(new GLatLng(parseFloat(this.result_.lat),
                                         parseFloat(this.result_.lng)),
                               opt_icon);
      GEvent.bind(marker, "click", this, function() {
        marker.openInfoWindow(this.selected() ? this.selectedHtml() :
                                                this.unselectedHtml());
      });
      this.marker_ = marker;
      return marker;
    }

    // "Saves" this result if it has not already been saved
    LocalResult.prototype.select = function() {
      if (!this.selected()) {
        this.selected_ = true;

        // Remove the old marker and add the new marker
        gMap.removeOverlay(this.marker());
        this.marker_ = null;
        gMap.addOverlay(this.marker(G_DEFAULT_ICON));

        // Add our result to the saved set
        document.getElementById("selected").appendChild(this.selectedHtml());

        // Remove the old search result from the search well
        this.resultNode_.parentNode.removeChild(this.resultNode_);
      }
    }

    // Returns the HTML we display for a result before it has been "saved"
    LocalResult.prototype.unselectedHtml = function() {
      var container = document.createElement("div");
      container.className = "unselected";
      container.appendChild(this.result_.html.cloneNode(true));
      var saveDiv = document.createElement("div");
      saveDiv.className = "select";
    //       saveDiv.innerHTML = "Save this location";
      GEvent.bindDom(saveDiv, "click", this, function() {
        gMap.closeInfoWindow();
        this.select();
        gSelectedResults.push(this);
      });
      container.appendChild(saveDiv);
      return container;
    }

    // Returns the HTML we display for a result after it has been "saved"
    LocalResult.prototype.selectedHtml = function() {
      return this.result_.html.cloneNode(true);
    }

    // Returns true if this result is currently "saved"
    LocalResult.prototype.selected = function() {
      return this.selected_;
    }

    //]]>

