﻿
/*    Walkmanマーカーの描画　 ----------------------------------------------------------*/

    function walkman(map, lng, lat, angle, pitch) {

    var myPano;
/*
      var walkman = new GIcon(G_DEFAULT_ICON);
      walkman.transparent = "http://maps.google.com/intl/en_us/mapfiles/cb/man-pick.png";
      walkman.imageMap = [
        26,13, 30,14, 32,28, 27,28, 28,36, 18,35, 18,27, 16,26,
        16,20, 16,14, 19,13, 22,8
      ];
      walkman.iconSize = new GSize(49, 52);
      walkman.iconAnchor = new GPoint(25, 35); 
      walkman.infoWindowAnchor = new GPoint(25, 5); 
*/
      myPano = new GStreetviewPanorama(document.getElementById("pano"));

      Point = new GLatLng(lat,lng);
      var direction = Math.round(angle/22.5);
      //walkman.image = "http://maps.google.com/intl/en_us/mapfiles/cb/man_arrow-"+direction+".png";
      myPOV = {yaw:angle,pitch:pitch};
      myPano.setLocationAndPOV(Point, myPOV);
      //marker = new GMarker(Point, {icon: walkman, draggable: false, bouncy: false});
      //map.addOverlay(marker);
      GEvent.addListener(myPano, "error", handleNoFlash);
/*
      GEvent.addListener(marker, "click", function() {
        myPano = new GStreetviewPanorama(document.getElementById("pano"));
        Point = new GLatLng(lat,lng);
        myPOV = {yaw:angle,pitch:pitch};
        myPano.setLocationAndPOV(Point, myPOV);
      });
*/
    }

    function handleNoFlash(errorCode) {
      if (errorCode == 603) {
        alert("エラー: Flashが使えません");
        return;
      }
    }

    function dropMarker(map,id,lng,lat,type,name,html,num) {
      /* アイコンの移動 */

      var marker;
      times = 15;
      speed = 20;
      for (i=0 ; i < times ; i++){
        x = lng;
        y = lat + (times-1-i)/times;
        var rtn = scrollT0("winkMarker(map,'"+id+"',"+x+","+y+",'"+type+"','"+name+"','" +html+ "' );",(num-1)*times*speed+i*speed); 
        //var rtn = scrollT0("winkMarker(map,"+x+","+y+",'" +html+ "' );",(num-1)*times*speed+i*speed); 
        if ( i < times-1 ) { var rtn = scrollT0("map.removeOverlay(marker);",(num-1)*times*speed+i*speed+speed-1); }

      }
   } 

    function winkMarker2(map,lng,lat,link) {

      var point = new GLatLng(lat, lng);
      marker = new GMarker(point);
      map.addOverlay(marker);

    }  

    function winkMarker(map,id,lng,lat,type,contents,link) {

      var icon = new GIcon();
      var point = new GLatLng(lat, lng);

      /* type に対応するアイコンのセット */

      if ( type == "" )   { type = "0"; }
    
      if ( (type >= "0") && (type <= "9")  )  {
         if (type == "1")	{ icon.image = "../img/red.png";    } else	
         if (type == "2")       { icon.image = "../img/yellow.png"; } else
         if (type == "3")       { icon.image = "../img/green.png";  } else
         if (type == "4")       { icon.image = "../img/blue.png";   } else
         if (type == "5")       { icon.image = "../img/purple.png"; } else
                                { icon.image = "../img/base.png";   }
      icon.iconSize = new GSize(20,34);
 /*     icon.shadow = "./img/shadow.png";  
      icon.shadowSize = new GSize(28, 28); */
      icon.iconAnchor = new GPoint(10, 34);
      icon.infoWindowAnchor = new GPoint(15, 1);
      }

      var options = { title: id,
                      icon : icon,
                      draggable: false,
                      bouncy: true};

      marker = new GMarker(point, options);

      if ( link == ""  )  {
          var html = "<b>" + id + "</b><hr width=\"320\" align=\"left\" color=\"ffcccc\">" + contents + ""; } else
        { var html = "<a href=\"" + link + "\" target=\"_blank\"><b>" + id + "</b></a><hr width=\"320\" align=\"left\" color=\"ffcccc\">" + contents + ""; 
      }

        GEvent.addListener(marker, "click", function() {
        map.openInfoWindowHtml(point,html);
        var splText = html.split("\"");
        work = splText[1]; 
        calframe = work.replace("car_trace","kiken");
        top.calframe.location.href = calframe;
       //top.calframe.location.href = "http://www.map-asp.net/Spatial_Gateway/CarInfo/kiken.cgi?filename=nikko.csv";
       // svOverlay = new GStreetviewOverlay();
       // map.addOverlay(svOverlay);
       // walkman(map,lng,lat,0,-30);
        var myPano;
        myPano = new GStreetviewPanorama(document.getElementById("pano"));
         // myPano = new GStreetviewPanorama(top.document.getElementById("pano"));
          myPOV = {yaw:0,pitch:-10};
          myPano.setLocationAndPOV(point, myPOV);
         // GEvent.addListener(myPano, "error", errorHandler);
        });

      map.addOverlay(marker);

    }  


