// JavaScript Document



var markers = [];

var marker_html = [];

var counter = 0;

var map;

/*

function onLoad() {

*/

function getMap( id, lat, lon, zoom, plat, plng ) {

	if (GBrowserIsCompatible()) {

		var target = document.getElementById("map" + id);

		if( target != undefined && id != 2){

			//alert(target);

			map = new GMap( target );

			map.setCenter( new GLatLng( lon, lat), zoom );

			map.addControl(new GSmallMapControl());

			GEvent.addListener(map, "click", addHistory);

			map.setMapType(G_MAP_TYPE);

			

				

			var point = new GPoint(plat,plng);

			var marker = addMarker(map, point, "");

			map.addOverlay(marker);

			

		} else if( id == 2 ){

			

			

			map = new GMap( target );

			map.setCenter( new GLatLng( lon, lat), zoom );

			map.addControl(new GSmallMapControl());

			GEvent.addListener(map, "click", addHistory);

			map.setMapType(G_MAP_TYPE);

			

				

			var point = new GPoint(plat,plng);

			var marker = addMarker(map, point, "");

			map.addOverlay(marker);

			

			

			var linePoints = [[ 35.677056091522,139.34447050094604 ],[ 35.67702123064474,139.3449318408966 ],[ 35.67700380020038,139.34544682502747 ],[ 35.67700380020038,139.34605836868286 ],[ 35.677064806738926,139.34663772583008 ],[ 35.67723039567989,139.34701323509216 ],[ 35.67747442086133,139.34718489646912 ],[ 35.67778816642672,139.34717416763306 ],[ 35.677997329451685,139.34685230255127 ],[ 35.67804090501289,139.34613347053528 ],[ 35.67838079357361,139.34422373771667 ],[ 35.67855509483804,139.3433439731598 ],[ 35.67882526104553,139.3428611755371 ],[ 35.67901699134757,139.34252858161926 ],[ 35.6791390012999,139.3422496318817 ],[ 35.67935687575081,139.34165954589844 ],[ 35.6794440253646,139.34118747711182 ],[ 35.67932201587864,139.34008240699768 ],[ 35.678982131326926,139.33820486068726 ],[ 35.67870325061349,139.336895942688 ],[ 35.67838079357361,139.3355655670166 ],[ 35.67816291645765,139.3344283103943 ],[ 35.67797118410354,139.33375239372253 ],[ 35.677640008952324,139.3329155445099 ],[ 35.67712581323084,139.33228254318237 ],[ 35.67679463457133,139.3320894241333 ],[ 35.67639373224993,139.33193922042847 ],[ 35.67584466710704,139.33201432228088 ],[ 35.675570133119024,139.33204114437103 ],[ 35.67503849318718,139.33233082294464 ],[ 35.67462450882049,139.3325400352478 ],[ 35.674110293669585,139.33258295059204 ],[ 35.673609148597464,139.3325239419937 ],[ 35.67317336771606,139.33226108551025 ],[ 35.672667858912796,139.33196604251862 ],[ 35.672049042053786,139.33175683021545 ],[ 35.67049762094992,139.3313491344452 ],[ 35.66843191795851,139.33078050613403 ],[ 35.66627028122259,139.3302172422409 ],[ 35.664418025762835,139.32971835136414 ],[ 35.662426258414925,139.32918190956116 ],[ 35.66095746160501,139.32887613773346 ],[ 35.660342912489455,139.32875275611877 ],[ 35.660530328678426,139.32594180107117 ],[ 35.660761329422414,139.32303428649902 ],[ 35.660861574820366,139.32075440883636 ],[ 35.66090080124619,139.31902170181274 ],[ 35.66090515973676,139.31860327720642 ],[ 35.66086593331309,139.31833505630493 ],[ 35.65980245403945,139.3161302804947 ],[ 35.65885228434773,139.31430101394653 ],[ 35.65807644933433,139.3127292394638 ],[ 35.65695191104732,139.310422539711 ],[ 35.65593632604093,139.30840015411377 ],[ 35.65498175153568,139.3066030740738 ],[ 35.65358256006816,139.30380284786224 ],[ 35.65232718985302,139.30474162101746 ],[ 35.65115026235713,139.305739402771 ],[ 35.650452815658184,139.30466651916504 ],[ 35.64896200291994,139.30214524269104 ],[ 35.64728807475892,139.29901242256165 ],[ 35.64625057042801,139.29717779159546 ]];

			

			// ラインの描画

			var lineLatLngPoints = [];

			for(i=0; i<linePoints.length; i++){

				lineLatLngPoints.push(new GLatLng(linePoints[i][0], linePoints[i][1]));

			}

	

			map.addOverlay(new GPolyline(lineLatLngPoints, '#00ff00'));



		} // end if

		

	} // end if

} // end of function









function click_sidebar(idx) {

	markers[idx].openInfoWindowHtml(marker_html[idx]);

}





function setMapData() {

	getMap( 1, 139.57718700170517, 35.70253096184879, 16, 139.57718700170517, 35.70253096184879 ) ;

	//getMap( 2, 139.322433, 35.66761, 12, 139.296965, 35.64631 ) ;	

}





function addMarker(map, point, html) {

	var marker = new GMarker(point);					

		markers[counter] = marker;

		marker_html[counter] = html;

		counter++;

		return marker;

}





var points = [];

var line = null;



function addHistory(ov, latlng){

	

	//alert( latlng );

	//alert(map);

	

	/*points.push( latlng );

	if( line != null ){

		map.removeOverlay( line );

	}

	

	line = new GPolyline( points, "#FF0000", 2);

	map.addOverlay( line );*/

	

}







onload = setMapData;


