
    var map;
    var myPano;
    var panoClient;
    var nextPanoId;
    var mapZoomDirection = "in";

    function gmap_load(lat,lng) {
      var geocode = new GLatLng(lat, lng);
      var POV_value = {yaw:370.64659986187695,pitch:-20};

      panoClient = new GStreetviewClient();

      map = new GMap2(document.getElementById("map_canvas"));
      map.setCenter(geocode, 14);
      GEvent.addListener(map, "click", function(overlay,latlng) {
        panoClient.getNearestPanorama(latlng, showPanoData);
      });
      map.addControl(new GLargeMapControl());
      //map.addControl(new GSmallMapControl());

      // マーカー表示
      var markeropt = new Object();
      markeropt.clickable = false;
      var marker = new GMarker(geocode, markeropt);
      //GEvent.addListener(marker, "click", function() {
      //  if (mapZoomDirection == "in" && map.getZoom() == 19) {
      //      mapZoomDirection = "out";
      //  }
      //  if (mapZoomDirection == "out" && map.getZoom() == 0) {
      //      mapZoomDirection = "in";
      //  }
      //  if (mapZoomDirection == "in") {
      //      map.zoomIn();
      //  } else {
      //      map.zoomOut();
      //  }
      //});
      map.addOverlay(marker);

      myPano = new GStreetviewPanorama(document.getElementById("pano"));
//      myPano.setLocationAndPOV(geocode, POV_value);
      GEvent.addListener(myPano, "error", handleNoFlash);
      panoClient.getNearestPanorama(geocode, showPanoData);

    }

    function showPanoData(panoData) {
      //StreetViewのデータ有無判定
      if (panoData.code != 200) {
        //GLog.write('showPanoData: Server rejected with code: ' + panoData.code);
        data = '<img src="http://' + location.host + '/buy/search/images/no_map_detail_01.gif" height="200" width="400">';
        document.getElementById('pano').innerHTML = data;
        return;
      }else{
        document.getElementById('pano').innerHTML = '';
      }
      nextPanoId = panoData.links[0].panoId;
      var displayString = [
        "Panorama ID: " + panoData.location.panoId,
        "LatLng: " + panoData.location.latlng,
        "Copyright: " + panoData.copyright,
        "Description: " + panoData.location.description,
        "Next Pano ID: " + panoData.links[0].panoId
      ].join("<br/>");
//      map.openInfoWindowHtml(panoData.location.latlng, displayString);

//      GLog.write('Viewer moved to' + panoData.location.latlng);
      myPano.setLocationAndPOV(panoData.location.latlng);
    }

    function next() {
      // Get the next panoId
      // Note that this is not sophisticated. At the end of the block, it will get stuck
      panoClient.getPanoramaById(nextPanoId, showPanoData);
    }
    
    function handleNoFlash(errorCode) {
      if (errorCode == 603) {
        alert("Error: Flash doesn't appear to be supported by your browser");
        return;
      }
    }
