﻿// Generated by trk2googlemaps and kml ( http://etgps.net/gps/ )
// 本コードはtrk2googlemaps and kmlによって自動生成されました。


var numofwaypoints = 0;
var posofwaypoints = 0;
var numofphotos = 15;
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,134.35615,35.0042833333333,"<b><a href=\""+relativepathtomainhtml+"#photoID1\">P1030256</a></b><br /><a href=\""+relativepathtosubfolder+"P1030256.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030256-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 11:04:01<br />E134°21’22.14”<br />N35°0’15.42”<br />101m<br />兵庫県佐用郡佐用町<hr />佐用町役場，保健センター付近．1m程度の浸水．</small>");
	addWayPoints(map, 1,134.35635,35.0053166666667,"<b><a href=\""+relativepathtomainhtml+"#photoID2\">P1030265</a></b><br /><a href=\""+relativepathtosubfolder+"P1030265.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030265-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 11:18:16<br />E134°21’22.86”<br />N35°0’19.14”<br />100m<br />兵庫県佐用郡佐用町<hr />自宅家屋内での犠牲者が生じた現場付近．浸水深は，道路面+1.8m程度．</small>");
	addWayPoints(map, 1,134.30525,35.0127833333333,"<b><a href=\""+relativepathtomainhtml+"#photoID3\">P1030275</a></b><br /><a href=\""+relativepathtosubfolder+"P1030275.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030275-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 11:38:40<br />E134°18’18.90”<br />N35°0’46.02”<br />118m<br />岡山県美作市<hr />3世帯9名の死者行方不明者が出た幕山町営住宅．左端車がある付近に端があり，右→左の方向に幕山川が流れる．</small>");
	addWayPoints(map, 1,134.30525,35.0127833333333,"<b><a href=\""+relativepathtomainhtml+"#photoID4\">P1030277</a></b><br /><a href=\""+relativepathtosubfolder+"P1030277.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030277-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 11:39:21<br />E134°18’18.90”<br />N35°0’46.02”<br />118m<br />岡山県美作市<hr />本郷公民館付近．電柱脇に水路が流れているが，この付近で犠牲者は流されたらしい．道路面に凹凸はないが，地形としては手前から奥に向かって下り勾配となっている．</small>");
	addWayPoints(map, 1,134.3055,35.0126833333333,"<b><a href=\""+relativepathtomainhtml+"#photoID5\">P1030278</a></b><br /><a href=\""+relativepathtosubfolder+"P1030278.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030278-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 11:40:21<br />E134°18’19.80”<br />N35°0’45.66”<br />117m<br />岡山県美作市<hr />犠牲者が生じた付近に残る洪水痕跡．電柱付近の痕跡物から見て，最大浸水深は1mには達せず，0.8mくらいか．</small>");
	addWayPoints(map, 1,134.305166666667,35.0121666666667,"<b><a href=\""+relativepathtomainhtml+"#photoID6\">P1030284</a></b><br /><a href=\""+relativepathtosubfolder+"P1030284.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030284-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 11:46:14<br />E134°18’18.60”<br />N35°0’43.80”<br />116m<br />岡山県美作市<hr />町営住宅付近の浸水痕跡は不明瞭だが，フェンス下部に浮遊物が見られることから，家屋付近の地表面+0.5m未満くらいか．</small>");
	addWayPoints(map, 1,134.30555,35.0120166666667,"<b><a href=\""+relativepathtomainhtml+"#photoID7\">P1030288</a></b><br /><a href=\""+relativepathtosubfolder+"P1030288.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030288-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 11:50:22<br />E134°18’19.98”<br />N35°0’43.26”<br />116m<br />岡山県美作市<hr />町営住宅前から．中央が本郷公民館．右奥が幕山小学校．公民館の脇を通り，小学校裏の保育所(指定避難場所)を目指したらしい．</small>");
	addWayPoints(map, 1,134.306066666667,35.0126833333333,"<b><a href=\""+relativepathtomainhtml+"#photoID8\">P1030295</a></b><br /><a href=\""+relativepathtosubfolder+"P1030295.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030295-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 12:15:24<br />E134°18’21.84”<br />N35°0’45.66”<br />117m<br />岡山県美作市<hr />公民館脇の幕山川．右の緑屋根が町営住宅．中央付近は扇状地状の地形で小高くなっている．扇状地上は浸水していない．鉄塔のある付近はさらに高所で，中国道上月PAがある．</small>");
	addWayPoints(map, 1,134.342983333333,34.9603833333333,"<b><a href=\""+relativepathtomainhtml+"#photoID9\">P1030312</a></b><br /><a href=\""+relativepathtosubfolder+"P1030312.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030312-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 13:18:03<br />E134°20’34.74”<br />N34°57’37.38”<br />68m<br />兵庫県赤穂郡上郡町苔縄<hr />久崎小学校前</small>");
	addWayPoints(map, 1,134.34135,34.9601333333333,"<b><a href=\""+relativepathtomainhtml+"#photoID10\">P1030319</a></b><br /><a href=\""+relativepathtosubfolder+"P1030319.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030319-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 13:22:50<br />E134°20’28.86”<br />N34°57’36.48”<br />67m<br />兵庫県赤穂郡上郡町岩木<hr />久崎付近の佐用川破堤箇所．堤体全体が流失したものではなく，天端から1～2m程度流失したような状況．緊急補修済み．</small>");
	addWayPoints(map, 1,134.341283333333,34.9600833333333,"<b><a href=\""+relativepathtomainhtml+"#photoID11\">P1030320</a></b><br /><a href=\""+relativepathtosubfolder+"P1030320.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030320-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 13:23:30<br />E134°20’28.62”<br />N34°57’36.30”<br />67m<br />兵庫県赤穂郡上郡町岩木<hr />破堤箇所付近の損壊家屋．この付近で人的被害は発生していない．</small>");
	addWayPoints(map, 1,134.341433333333,34.9594666666667,"<b><a href=\""+relativepathtomainhtml+"#photoID12\">P1030330</a></b><br /><a href=\""+relativepathtosubfolder+"P1030330.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030330-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 14:01:39<br />E134°20’29.16”<br />N34°57’34.08”<br />66m<br />兵庫県赤穂郡上郡町岩木<hr /></small>");
	addWayPoints(map, 1,134.341633333333,34.9594666666667,"<b><a href=\""+relativepathtomainhtml+"#photoID13\">P1030331</a></b><br /><a href=\""+relativepathtosubfolder+"P1030331.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030331-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 14:08:07<br />E134°20’29.88”<br />N34°57’34.08”<br />66m<br />兵庫県赤穂郡上郡町岩木<hr /></small>");
	addWayPoints(map, 1,134.341833333333,34.9587333333333,"<b><a href=\""+relativepathtomainhtml+"#photoID14\">P1030337</a></b><br /><a href=\""+relativepathtosubfolder+"P1030337.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030337-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 14:11:26<br />E134°20’30.60”<br />N34°57’31.44”<br />64m<br />兵庫県赤穂郡上郡町苔縄<hr />久崎付近．ほぼ１階天井付近まで浸水痕跡が見られる．</small>");
	addWayPoints(map, 1,134.352583333333,35.0041333333333,"<b><a href=\""+relativepathtomainhtml+"#photoID15\">P1030362</a></b><br /><a href=\""+relativepathtosubfolder+"P1030362.jpg\"  target=\"_blank\"><img src=\""+relativepathtosubfolder+"P1030362-thumb.jpg\" border=\"0\" width=\"128\" height=\"96\" /></a><br /><small>2009:08:14 16:32:19<br />E134°21’9.30”<br />N35°0’14.88”<br />103m<br />兵庫県佐用郡佐用町<hr />佐用共立病院前．道路は手前から奥に向かって下がって．この付近で，車で移動中の1名が流され死亡した模様．</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.9587333333333, 134.305166666667), new GLatLng(35.0127833333333,134.35635) );
	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;
}


