﻿// Generated by trk2googlemaps and kml ( http://etgps.net/gps/ )
// 本コードはtrk2googlemaps and kmlによって自動生成されました。


var numofwaypoints = 0;
var posofwaypoints = 0;
var numofphotos = 21;
var posofphotos = 0;
var waypoint_markers = [];
var waypoint_infos   = [];
var photo_markers    = [];
var photo_infos      = [];
var points = [];
var map;
var currentzoom;
var key = "ABQIAAAANH23qKVVYp-Ce4L2A2JIehR8a0MCIjlbwdS61MB5LIeWccDibRQ1pSwj0273r6fxq1iLeFTOSZzmgg";
var gcurrent;
var jsondata;

   

// ウェイポイント表示用関数
function addWayPoints(map, nType, lat, lon, title)
{
	var point=new GLatLng(lon, lat);
	var Icon = new GIcon();
	var nn;
	if (nType==1){ // 小さな赤いマーカ
		nn=posofphotos+1;
		Icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
		Icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		Icon.iconSize = new GSize(12, 20);
		Icon.shadowSize = new GSize(22, 20);
		Icon.iconAnchor = new GPoint(6, 20);
		Icon.infoWindowAnchor = new GPoint(5, 1);

		photo_markers.push(new GMarker(point, Icon));
		photo_infos.push('<div style="width: 12em; style: font-size: small">'+title+'</div>');
		if (map != null){
			GEvent.addListener(photo_markers[posofphotos], "click", function(){jumpphotomarker(nn);});
			map.addOverlay(photo_markers[posofphotos]);
		}
		posofphotos = posofphotos+1;

	}
	else
	{ // |>の形状のマーカ
		nn=posofwaypoints+1;
		Icon.image = "http://www.google.com/mapfiles/dd-start.png";
		Icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
		Icon.iconSize = new GSize(20, 34);
		Icon.shadowSize = new GSize(37, 34);
		Icon.iconAnchor = new GPoint(9, 34);
		Icon.infoWindowAnchor = new GPoint(9, 2);

		waypoint_markers.push(new GMarker(point, Icon));
		waypoint_infos.push('<div style="width: 12em; style: font-size: small">'+title+'</div>');
		if (map != null){
			GEvent.addListener(waypoint_markers[posofwaypoints], "click",function(){jumpwaypointmarker(nn);});
			map.addOverlay(waypoint_markers[posofwaypoints]);
		}
		posofwaypoints=posofwaypoints+1;
	}
}

// 写真表示モードロード時	
function photo_load()
{
	AddAllWaypoints();
}
// ウェイポイント追加
function AddAllWaypoints()
{
	addWayPoints(map, 1,131.576383333333,34.0921666666667,"<b><a href=\""+relativepathtomainhtml+"#photoID1\">P1030087</a></b><br /><a href=\""+relativepathtosubfolder+"P1030087.jpg\"><img src=\""+relativepathtosubfolder+"P1030087-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 11:30:53<br />E131°34’34.98”<br />N34°5’31.80”<br />19m<br />山口県防府市上右田<hr />防府市上右田・沖の口地区<br />阿部谷川で発生した土石流が堰堤で補足されている状況．</small>");
	addWayPoints(map, 1,131.574516666667,34.0926333333333,"<b><a href=\""+relativepathtomainhtml+"#photoID2\">P1030091</a></b><br /><a href=\""+relativepathtosubfolder+"P1030091.jpg\"><img src=\""+relativepathtosubfolder+"P1030091-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 11:36:20<br />E131°34’28.26”<br />N34°5’33.48”<br />21m<br />山口県防府市上右田<hr />流出土砂末端部．末端部とはいえ，車が流されて土砂に埋まっている．</small>");
	addWayPoints(map, 1,131.573383333333,34.0910333333333,"<b><a href=\""+relativepathtomainhtml+"#photoID3\">P1030103</a></b><br /><a href=\""+relativepathtosubfolder+"P1030103.jpg\"><img src=\""+relativepathtosubfolder+"P1030103-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 11:42:36<br />E131°34’24.18”<br />N34°5’27.72”<br />26m<br />山口県防府市上右田<hr />谷出口直下付近．左の家屋は1階の半分ほどが土砂に埋没している．</small>");
	addWayPoints(map, 1,131.573083333333,34.09065,"<b><a href=\""+relativepathtomainhtml+"#photoID4\">P1030108</a></b><br /><a href=\""+relativepathtosubfolder+"P1030108.jpg\"><img src=\""+relativepathtosubfolder+"P1030108-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 11:44:06<br />E131°34’23.10”<br />N34°5’26.34”<br />24m<br />山口県防府市上右田<hr />これがもとの阿部谷川流路．草の生えている部分が堤防だった．完全に土砂に埋まっているが，巨レキは流路内にとどまっている．</small>");
	addWayPoints(map, 1,131.572516666667,34.08955,"<b><a href=\""+relativepathtomainhtml+"#photoID5\">P1030117</a></b><br /><a href=\""+relativepathtosubfolder+"P1030117.jpg\"><img src=\""+relativepathtosubfolder+"P1030117-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 11:51:41<br />E131°34’21.06”<br />N34°5’22.38”<br />19m<br />山口県防府市上右田<hr />阿部谷川は，左の石垣部付近から右の林付近を流れる．周囲より流路が高く，天井川となっている．</small>");
	addWayPoints(map, 1,131.5749,34.0896333333333,"<b><a href=\""+relativepathtomainhtml+"#photoID6\">P1030121</a></b><br /><a href=\""+relativepathtosubfolder+"P1030121.jpg\"><img src=\""+relativepathtosubfolder+"P1030121-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 11:55:44<br />E131°34’29.64”<br />N34°5’22.68”<br />18m<br />山口県防府市上右田<hr />県道と阿部谷川の交差部．天井川であることがよくわかる．住民によると，日常は流れのない川とのこと．</small>");
	addWayPoints(map, 1,131.603716666667,34.0999333333333,"<b><a href=\""+relativepathtomainhtml+"#photoID7\">P1030153</a></b><br /><a href=\""+relativepathtosubfolder+"P1030153.jpg\"><img src=\""+relativepathtosubfolder+"P1030153-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 13:00:24<br />E131°36’13.38”<br />N34°5’59.76”<br />44m<br />山口県防府市牟礼<hr />防府市真尾．老人ホームライフケア高砂前の真尾川に流れ込む流水．</small>");
	addWayPoints(map, 1,131.604433333333,34.0996833333333,"<b><a href=\""+relativepathtomainhtml+"#photoID8\">P1030158</a></b><br /><a href=\""+relativepathtosubfolder+"P1030158.jpg\"><img src=\""+relativepathtosubfolder+"P1030158-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 13:05:45<br />E131°36’15.96”<br />N34°5’58.86”<br />46m<br />山口県防府市牟礼<hr />老人ホームの玄関．現在も勢いよく水が流れる．大きなレキはなく，砂と径数十cm程度のレキが堆積している．</small>");
	addWayPoints(map, 1,131.605433333333,34.0997166666667,"<b><a href=\""+relativepathtomainhtml+"#photoID9\">P1030170</a></b><br /><a href=\""+relativepathtosubfolder+"P1030170.jpg\"><img src=\""+relativepathtosubfolder+"P1030170-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 14:17:40<br />E131°36’19.56”<br />N34°5’58.98”<br />51m<br />山口県防府市牟礼<hr />老人ホーム建物裏側に堆積する土石流．1階天井付近まで堆積が見られ，2階の壁にもしぶきがかかっている．</small>");
	addWayPoints(map, 1,131.6054,34.0997166666667,"<b><a href=\""+relativepathtomainhtml+"#photoID10\">P1030172</a></b><br /><a href=\""+relativepathtosubfolder+"P1030172.jpg\"><img src=\""+relativepathtosubfolder+"P1030172-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 14:17:53<br />E131°36’19.44”<br />N34°5’58.98”<br />51m<br />山口県防府市牟礼<hr />山側を見る．この付近では1m以上のレキも見られる．</small>");
	addWayPoints(map, 1,131.591266666667,34.09975,"<b><a href=\""+relativepathtomainhtml+"#photoID11\">P1030180</a></b><br /><a href=\""+relativepathtosubfolder+"P1030180.jpg\"><img src=\""+relativepathtosubfolder+"P1030180-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 14:41:22<br />E131°35’28.56”<br />N34°5’59.10”<br />24m<br />山口県防府市真尾<hr />防府市真尾・石原地区．集落まで流下した土石流で損壊した民家．</small>");
	addWayPoints(map, 1,131.591266666667,34.09975,"<b><a href=\""+relativepathtomainhtml+"#photoID12\">P1030181</a></b><br /><a href=\""+relativepathtosubfolder+"P1030181.jpg\"><img src=\""+relativepathtosubfolder+"P1030181-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 14:41:24<br />E131°35’28.56”<br />N34°5’59.10”<br />24m<br />山口県防府市真尾<hr /></small>");
	addWayPoints(map, 1,131.591266666667,34.09975,"<b><a href=\""+relativepathtomainhtml+"#photoID13\">P1030182</a></b><br /><a href=\""+relativepathtosubfolder+"P1030182.jpg\"><img src=\""+relativepathtosubfolder+"P1030182-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 14:41:29<br />E131°35’28.56”<br />N34°5’59.10”<br />24m<br />山口県防府市真尾<hr /></small>");
	addWayPoints(map, 1,131.591266666667,34.09975,"<b><a href=\""+relativepathtomainhtml+"#photoID14\">P1030183</a></b><br /><a href=\""+relativepathtosubfolder+"P1030183.jpg\"><img src=\""+relativepathtosubfolder+"P1030183-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 14:41:34<br />E131°35’28.56”<br />N34°5’59.10”<br />24m<br />山口県防府市真尾<hr /></small>");
	addWayPoints(map, 1,131.58855,34.1043833333333,"<b><a href=\""+relativepathtomainhtml+"#photoID15\">P1030184</a></b><br /><a href=\""+relativepathtosubfolder+"P1030184.jpg\"><img src=\""+relativepathtosubfolder+"P1030184-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 14:47:38<br />E131°35’18.78”<br />N34°6’15.78”<br />31m<br />山口県防府市真尾<hr />石原地区の土石流を対岸から見る．</small>");
	addWayPoints(map, 1,131.55235,34.0770666666667,"<b><a href=\""+relativepathtomainhtml+"#photoID16\">P1030191</a></b><br /><a href=\""+relativepathtosubfolder+"P1030191.jpg\"><img src=\""+relativepathtosubfolder+"P1030191-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 15:16:49<br />E131°33’8.46”<br />N34°4’37.44”<br />32m<br />山口県防府市高井<hr />防府市下右田・山ノ口地区を流れる剣川．流路が土砂でほぼ埋積されており，河床の急上昇により洪水状の状況になったと思われる．</small>");
	addWayPoints(map, 1,131.55085,34.0803333333333,"<b><a href=\""+relativepathtomainhtml+"#photoID17\">P1030199</a></b><br /><a href=\""+relativepathtosubfolder+"P1030199.jpg\"><img src=\""+relativepathtosubfolder+"P1030199-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 15:23:45<br />E131°33’3.06”<br />N34°4’49.20”<br />47m<br />山口県防府市下右田<hr />防府市下右田．国道262号線沿いに見られる土砂流出．</small>");
	addWayPoints(map, 1,131.549316666667,34.0826166666667,"<b><a href=\""+relativepathtomainhtml+"#photoID18\">P1030203</a></b><br /><a href=\""+relativepathtosubfolder+"P1030203.jpg\"><img src=\""+relativepathtosubfolder+"P1030203-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 15:27:46<br />E131°32’57.54”<br />N34°4’57.42”<br />61m<br />山口県防府市下右田<hr />国道262号沿いでは何カ所かの土砂流出が見られるが，ここがもっとも大規模な現場．道路対岸の渓流から土石流が流下し，谷を越えて道路側に達したと思われる．</small>");
	addWayPoints(map, 1,131.549083333333,34.0828833333333,"<b><a href=\""+relativepathtomainhtml+"#photoID19\">P1030206</a></b><br /><a href=\""+relativepathtosubfolder+"P1030206.jpg\"><img src=\""+relativepathtosubfolder+"P1030206-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 15:38:31<br />E131°32’56.70”<br />N34°4’58.38”<br />60m<br />山口県防府市下右田<hr />この付近では，流出土砂により4車線のうち2車線が完全に埋没している状況．</small>");
	addWayPoints(map, 1,131.550866666667,34.0804666666667,"<b><a href=\""+relativepathtomainhtml+"#photoID20\">P1030221</a></b><br /><a href=\""+relativepathtosubfolder+"P1030221.jpg\"><img src=\""+relativepathtosubfolder+"P1030221-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 16:07:59<br />E131°33’3.12”<br />N34°4’49.68”<br />46m<br />山口県防府市下右田<hr />流されて土砂に埋まっている車．通行中だったものと思われる．</small>");
	addWayPoints(map, 1,131.551066666667,34.0800166666667,"<b><a href=\""+relativepathtomainhtml+"#photoID21\">P1030223</a></b><br /><a href=\""+relativepathtosubfolder+"P1030223.jpg\"><img src=\""+relativepathtosubfolder+"P1030223-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:07:22 16:08:56<br />E131°33’3.84”<br />N34°4’48.06”<br />42m<br />山口県防府市下右田<hr />付近ではこのような状態の車が多数放置されていた．</small>");

	return;
}
// ストリートビュー初期化
function InitStreetView()
{
	streetObj = new GStreetviewPanorama(document.getElementById("streetview"));
	GEvent.addListener(streetObj, "error", 
	function(err){
	    if (err == 600 || err == 603) {
	        timerID3 = window.setTimeout(function() { streetObj.remove(); clearTimeout(timerID3); }, 600); // 少しディレイさせて消去
	    }
		return;
	});
}
// HTMLロード時
function load()
{
	// 初期化パラメータ
	var mapwidth=640;  // 地図の幅を設定します。
	var mapheight=480; // 地図の高さを設定します。
	var zoom=-1;    // この値を変更すると初期ズーム値が変わります。-1の場合は自動となります。
	var defaultmaptype=0; // この値を変更すると初期のマップタイプが変更されます。
	var wpt_points = [];
	
	var region=new GLatLngBounds( new GLatLng(34.0770666666667, 131.549083333333), new GLatLng(34.1043833333333,131.605433333333) );
	var centerpos= region.getCenter();
	
	// マップ初期化	
	map = new GMap2(document.getElementById("map"));
	map.addControl(new GLargeMapControl());
	map.addMapType(G_PHYSICAL_MAP);
	map.addControl(new GHierarchicalMapTypeControl());
	map.enableContinuousZoom();
	map.enableDoubleClickZoom();
	map.addControl(new GOverviewMapControl());
	if (zoom>0)
	{
		map.setCenter(centerpos, 17-zoom);
	}
	else
	{
		map.setCenter(centerpos, map.getBoundsZoomLevel(region));
	}
	
	// 軌跡再生アイコン
	movemarkerIcon = new GIcon();
	movemarkerIcon.iconSize = new GSize(32, 32);
	movemarkerIcon.shadowSize = new GSize(59, 32);
	movemarkerIcon.iconAnchor = new GPoint(16, 16);
	movemarkerIcon.infoWindowAnchor = new GPoint(1, 1);
	movemarkerIcon.image = "http://maps.google.co.jp/mapfiles/ms/icons/hospitals.png";
	movemarkerIcon.shadow = "http://maps.google.co.jp/mapfiles/ms/icons/hospitals.shadow.png";
	
	// 初期マップタイプ設定
	switch(defaultmaptype)
	{
		case 0:
		map.setMapType(G_NORMAL_MAP);   	//This is the normal street map type.
		break;
		
		case 1:
		map.setMapType(G_SATELLITE_MAP); //This map type shows Google Earth satellite images.
		break;
	
		case 2:
		map.setMapType(G_HYBRID_MAP); 	//This map type shows transparent street maps over Google Earth satellite images.
		break;
		
		case 3:
		map.setMapType(G_PHYSICAL_MAP); 
		break;		
	
		default:
		map.setMapType(G_NORMAL_MAP);
		break;
	}
	AddAllWaypoints();

	if (numofwaypoints == 0)
	{
		hiddenLAYER('waypointcombo');
	}
	if (numofphotos==0)
	{
		hiddenLAYER('photocombo');
	}
	if (callHiddenLayers==1)
	{
		hiddenLayers();
	}
	
    GDownloadUrl(relativepathtosubfolder + "data.json", loadTrackLog);
	
} // end of load() function.


var polylineid;
// トラックログ情報のロード
function loadTrackLog(jsontext, statusCode)
{
    if (statusCode != 200 && statusCode != 0)
    {
        alert("Reading json file failed :" +statusCode.toString());
        return;
    }
    try
    {
	    jsondata = eval("(" + jsontext + ")");
	}catch (e)
	{
        alert("Parsing json file failed :" + e.toString());
	}
	if (jsondata.encoded_points != null){
        polylineid=0;
	    setTimeout(loadEncodedPolylines, 17);
	}
}

// Polylineを描画する。
function loadEncodedPolylines()
{
    var encodedPolyline = new GPolyline.fromEncoded({
   		color: jsondata.linecolors[polylineid],
  		weight: jsondata.linewidth[polylineid],
   		opacity : jsondata.lineopacities[polylineid],
   		points: jsondata.encoded_points[polylineid],
   		levels: jsondata.encoded_levels[polylineid],
   		zoomFactor: 4,
   		numLevels: 9
   			});
	map.addOverlay(encodedPolyline); 
	polylineid++;
	if (jsondata.encoded_points.length > polylineid)
	{
	    setTimeout(loadEncodedPolylines, 17); // 33msec毎に制御を一旦返す。
	}
}




// 指定された写真へジャンプ
function jumpphotomarker(n)
{
    if (n < 1) return;
    
	photo_markers[n-1].openInfoWindowHtml(photo_infos[n-1]);
	location.hash="#googlemap";

}
	
// 指定されたマーカーへジャンプ
function jumpwaypointmarker(n)
{
	waypoint_markers[n-1].openInfoWindowHtml(waypoint_infos[n-1]);
	location.hash="#googlemap";
}

// グラフは初期状態では消しておく
function hiddenLayers()
{
}

// 指定したレイヤーを非表示にする
function hiddenLAYER(idName)
{ 
    if (idName == null)
    {
        // nullなら何もしない。
        return;
    }
	if ( document.getElementById )
	{
	    if (document.getElementById( idName ) == null)
	    {
	        return;
	    }
		document.getElementById( idName ).style.visibility='hidden';
	}
	else if ( document.all )
	{
	    if (document.all( idName ) == null) 
	    {
	        return;
	    }
		document.all( idName ).style.visibility = 'hidden';
	}
}

// 指定したレイヤーを表示する
function showLAYER(idName)
{
    if (idName == null)
    {
        // nullなら何もしない。
        return;
    }
    
    if ( document.getElementById )
	{
	    if (document.getElementById( idName ) == null)
	    {
	        return;
	    }
		document.getElementById( idName ).style.visibility   = 'visible';
	}
	else if ( document.all )
	{
	    if (document.all( idName ) == null) 
	    {
	        return;
	    }
		document.all( idName ).style.visibility = 'visible'; // Ie6対策
	}
}

// 地図を表示する
function showMapPop( idName, lat, lon )
{ 
    if (idName == null){
        return;
    }
	var svalue;
	var zoomlevel;
	var i = idName.slice(6);
	if (i < 1){
	    return;
	}
	moveSVLocationLatLon(photo_markers[Number(i) - 1].getPoint());
	
	if (map == null)
	{
		if (currentzoom == null)
		{
			zoomlevel=12; // 指定がない場合	
		}
		else
		{
			zoomlevel=currentzoom; // htmlファイルに?xxでズームレベルが渡されたとき
		}
	}
	else
	{
		zoomlevel=map.getZoom();
	}
	svalue = ".<img src=\"http://maps.google.com/staticmap?center="+lat+","+lon+"&markers="+lat+","+lon+",blue&zoom="+zoomlevel+"&size=240x240&key="+key+"\" width=\"240\" height=\"240\"  />.";

	if ( document.getElementById )
	{
		document.getElementById( idName ).style.display="block";
		document.getElementById( idName ).innerHTML = svalue;
	}
	else if ( document.all ) 
	{
		 document.all( idName ).style.display="block"; // Ie6対策
		 document.all( idName ).innerHTML=svalue;
	}

}

// 地図を消す
function hideMapPop( idName )
{
	if ( document.getElementById )
	{
		document.getElementById( idName ).style.display="none";
	}
	else if ( document.all )
	{
		document.all( idName ).style.display="none"; // Ie6対策
	}
}

// ズームレベルを渡しながらページを移動する。
function goPhotopage(url, hash)
{
	location.href=url+"?"+map.getZoom()+hash;
}

